]> 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 e79772e0ec3f954a402e9280b040c57d209c2d5d..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());
@@ -522,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