On 01/10/2008 01:37, Uwe Stöhr wrote:
>> When no Qt functions are used we have to switch between "/" and "\"
manually:
>
> What about this patch?
It doesn't fix the bug.
I don't understand why this bug appears only in trunk and not in
branch. And I also don't understand why this bug disappears as soon as
I pressed OK in the preferences dialog and then restarted LyX.
Really strange is that this bug is really not there when using Vista,
but in Win200 and WinXP.
I just committed a few fixes, please try again. Thanks to Peter for
putting me on the right track (I hope).
Abdel.
Author: younes
Date: Wed Oct 1 11:36:01 2008
New Revision: 26669
URL:http://www.lyx.org/trac/changeset/26669
Log:
Attempt to fixhttp://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.
Modified:
lyx-devel/trunk/src/support/FileName.cpp
Modified: lyx-devel/trunk/src/support/FileName.cpp
URL:http://www.lyx.org/trac/file/lyx-devel/trunk/src/support/FileName.cpp?rev=26669
==============================================================================
--- lyx-devel/trunk/src/support/FileName.cpp (original)
+++ lyx-devel/trunk/src/support/FileName.cpp Wed Oct 1 11:36:01 2008
@@ -346,7 +346,7 @@
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 @@
}
+// 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 @@
bool FileName::createDirectory(int permission) const
{
+ 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(), /**/);
- return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;
-}
-
-
-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());