]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
CMake: fix merged build, seems GCC could not handle the namespaces correctly
[lyx.git] / src / support / FileName.cpp
index 07af66d8734fad4e94b723803f31513653730e88..e79772e0ec3f954a402e9280b040c57d209c2d5d 100644 (file)
@@ -13,7 +13,6 @@
 #include "support/FileName.h"
 #include "support/FileNameList.h"
 
-#include "support/convert.h"
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/lassert.h"
 #include <cerrno>
 #include <fcntl.h>
 
-#if defined(HAVE_MKSTEMP) && ! defined(HAVE_DECL_MKSTEMP)
-extern "C" int mkstemp(char *);
-#endif
-
-#if !defined(HAVE_MKSTEMP) && defined(HAVE_MKTEMP)
-# ifdef HAVE_IO_H
-#  include <io.h>
-# endif
-# ifdef HAVE_PROCESS_H
-#  include <process.h>
-# endif
-#endif
-
 // Three implementations of checksum(), depending on having mmap support or not.
 #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
 #define SUM_WITH_MMAP
@@ -105,17 +91,15 @@ struct FileName::Private
 
        Private(string const & abs_filename) : fi(toqstr(abs_filename))
        {
-               name = abs_filename;
+               name = fromqstr(fi.absoluteFilePath());
                fi.setCaching(fi.exists() ? true : false);
        }
        ///
        inline void refresh() 
        {
-// There seems to be a bug in Qt >= 4.2.0, at least, that causes problems with
+// There seems to be a bug in Qt >= 4.2.0 and < 4.5.0, that causes problems with
 // QFileInfo::refresh() on *nix. So we recreate the object in that case.
-// FIXME: When Trolltech fixes the bug, we will have to replace 0x999999 below
-// with the actual working minimum version.
-#if defined(_WIN32) || (QT_VERSION >= 0x999999)
+#if defined(_WIN32) || (QT_VERSION >= 0x040500)
                fi.refresh();
 #else
                fi = QFileInfo(fi.absoluteFilePath());
@@ -212,8 +196,8 @@ string FileName::realPath() const
 
 void FileName::set(string const & name)
 {
-       d->name = name;
        d->fi.setFile(toqstr(name));
+       d->name = fromqstr(d->fi.absoluteFilePath());
        //LYXERR(Debug::FILES, "FileName::set(" << name << ')');
        LASSERT(empty() || isAbsolute(d->name), /**/);
 }
@@ -407,7 +391,9 @@ FileNameList FileName::dirList(string const & ext) const
                return dirlist;
        }
 
-       QDir dir = d->fi.absoluteDir();
+       // If the directory is specified without a trailing '/', absoluteDir()
+       // would return the parent dir, so we must use absoluteFilePath() here.
+       QDir dir = d->fi.absoluteFilePath();
 
        if (!ext.empty()) {
                QString filter;
@@ -474,6 +460,12 @@ FileName FileName::tempPath()
 }
 
 
+void FileName::refresh() const
+{
+       d->refresh();
+}
+
+
 time_t FileName::lastModified() const
 {
        // QFileInfo caches information about the file. So, in case this file has
@@ -512,7 +504,7 @@ unsigned long FileName::checksum() const
 #if QT_VERSION >= 0x999999
        // First version of checksum uses Qt4.4 mmap support.
        // FIXME: This code is not ready with Qt4.4.2,
-       // see http://bugzilla.lyx.org/show_bug.cgi?id=5293
+       // see http://www.lyx.org/trac/ticket/5293
        // FIXME: should we check if the MapExtension extension is supported?
        // see QAbstractFileEngine::supportsExtension() and 
        // QAbstractFileEngine::MapExtension)