]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
tiger support on mac snow leopard, include Qt4 frameworks, smart build script with...
[lyx.git] / src / support / FileName.cpp
index 09984fdab0ea24d30c3c4c8796d2575b905d8244..96aa4da93feaca12e28cc7a2943ed8b377c9886e 100644 (file)
@@ -66,6 +66,7 @@
 #endif // SUM_WITH_MMAP
 
 using namespace std;
+using namespace lyx::support;
 
 // OK, this is ugly, but it is the only workaround I found to compile
 // with gcc (any version) on a system which uses a non-GNU toolchain.
@@ -190,7 +191,7 @@ string FileName::absFilename() const
 
 string FileName::realPath() const
 {
-       return os::real_path(toFilesystemEncoding());
+       return os::real_path(absFilename());
 }
 
 
@@ -270,13 +271,22 @@ bool FileName::changePermission(unsigned long int mode) const
 
 string FileName::toFilesystemEncoding() const
 {
-       // FIXME: This doesn't work on Windows for non ascii file names with Qt < 4.4.
-       // Provided that Windows package uses Qt4.4, this isn't a problem.
+       // This doesn't work on Windows for non ascii file names.
        QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath());
        return string(encoded.begin(), encoded.end());
 }
 
 
+string FileName::toSafeFilesystemEncoding(os::file_access how) const
+{
+       // This will work on Windows for non ascii file names.
+       QString const safe_path =
+               toqstr(os::safe_internal_path(absFilename(), how));
+       QByteArray const encoded = QFile::encodeName(safe_path);
+       return string(encoded.begin(), encoded.end());
+}
+
+
 FileName FileName::fromFilesystemEncoding(string const & name)
 {
        QByteArray const encoded(name.c_str(), name.length());
@@ -460,6 +470,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
@@ -498,7 +514,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)
@@ -516,7 +532,7 @@ unsigned long FileName::checksum() const
 
 #else // QT_VERSION
 
-       string const encoded = toFilesystemEncoding();
+       string const encoded = toSafeFilesystemEncoding();
        char const * file = encoded.c_str();
 
  #ifdef SUM_WITH_MMAP