]> git.lyx.org Git - features.git/commitdiff
Attempt to fix http://bugzilla.lyx.org/show_bug.cgi?id=4693
authorAbdelrazak Younes <younes@lyx.org>
Wed, 1 Oct 2008 09:36:01 +0000 (09:36 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 1 Oct 2008 09:36:01 +0000 (09:36 +0000)
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

src/support/FileName.cpp

index 35c0f136d746f39c16bf3e5bee4c72a8fbabf4cd..48a2e3c67f60818b023f8fc040a3803c71f5e293 100644 (file)
@@ -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());