From: Abdelrazak Younes Date: Wed, 1 Oct 2008 09:36:01 +0000 (+0000) Subject: Attempt to fix http://bugzilla.lyx.org/show_bug.cgi?id=4693 X-Git-Tag: 1.6.10~3225 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c7a28bbec7fe78b9336fd7c18de6e396dc606197;p=features.git 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 --- diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 35c0f136d7..48a2e3c67f 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -346,7 +346,7 @@ bool FileName::isWritable() const bool FileName::isDirWritable() const { LASSERT(d->fi.isDir(), return false); - QFileInfo tmp(d->fi.absoluteDir(), "lyxwritetest"); + QFileInfo tmp(QDir(d->fi.absoluteFilePath()), "lyxwritetest"); QTemporaryFile qt_tmp(tmp.absoluteFilePath()); if (qt_tmp.open()) { 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) { // 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 { - 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; +#endif } bool FileName::createPath() const { LASSERT(!empty(), /**/); + LYXERR(Debug::FILES, "creating path '" << *this << "'."); if (isDirectory()) - return true; + return false; QDir dir; bool success = dir.mkpath(d->fi.absoluteFilePath());