mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Attempt to fix http://bugzilla.lyx.org/show_bug.cgi?id=4693
isDirWritable(): make it work when there is no trailing slash! createPath(): return false if the directory already exists. createDirectory(): don't use mymkdir on Windows, use createPath() instead. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26669 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0ac664310a
commit
c7a28bbec7
@ -346,7 +346,7 @@ bool FileName::isWritable() const
|
|||||||
bool FileName::isDirWritable() const
|
bool FileName::isDirWritable() const
|
||||||
{
|
{
|
||||||
LASSERT(d->fi.isDir(), return false);
|
LASSERT(d->fi.isDir(), return false);
|
||||||
QFileInfo tmp(d->fi.absoluteDir(), "lyxwritetest");
|
QFileInfo tmp(QDir(d->fi.absoluteFilePath()), "lyxwritetest");
|
||||||
QTemporaryFile qt_tmp(tmp.absoluteFilePath());
|
QTemporaryFile qt_tmp(tmp.absoluteFilePath());
|
||||||
if (qt_tmp.open()) {
|
if (qt_tmp.open()) {
|
||||||
LYXERR(Debug::FILES, "Directory " << *this << " is writable");
|
LYXERR(Debug::FILES, "Directory " << *this << " is writable");
|
||||||
@ -591,6 +591,7 @@ bool FileName::destroyDirectory() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Only used in non Win32 platforms
|
||||||
static int mymkdir(char const * pathname, unsigned long int mode)
|
static int mymkdir(char const * pathname, unsigned long int mode)
|
||||||
{
|
{
|
||||||
// FIXME: why don't we have mode_t in lyx::mkdir prototype ??
|
// FIXME: why don't we have mode_t in lyx::mkdir prototype ??
|
||||||
@ -619,16 +620,22 @@ static int mymkdir(char const * pathname, unsigned long int mode)
|
|||||||
|
|
||||||
bool FileName::createDirectory(int permission) const
|
bool FileName::createDirectory(int permission) const
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), return false);
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
// FIXME: "Permissions of created directories are ignored on this system."
|
||||||
|
return createPath();
|
||||||
|
#else
|
||||||
return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;
|
return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileName::createPath() const
|
bool FileName::createPath() const
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), /**/);
|
||||||
|
LYXERR(Debug::FILES, "creating path '" << *this << "'.");
|
||||||
if (isDirectory())
|
if (isDirectory())
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
bool success = dir.mkpath(d->fi.absoluteFilePath());
|
bool success = dir.mkpath(d->fi.absoluteFilePath());
|
||||||
|
Loading…
Reference in New Issue
Block a user