]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
add generic helper class for calling functions in gui thread
[lyx.git] / src / support / FileName.cpp
index 5ba2af2524ae62eae10d5ac38a2a5bf110246b03..54c6fc9fd9859c909fdb1871867176901dab0e05 100644 (file)
@@ -183,7 +183,7 @@ bool FileName::isAbsolute(string const & name)
 }
 
 
-string FileName::absFilename() const
+string FileName::absFileName() const
 {
        return d->name;
 }
@@ -191,7 +191,7 @@ string FileName::absFilename() const
 
 string FileName::realPath() const
 {
-       return os::real_path(absFilename());
+       return os::real_path(absFileName());
 }
 
 
@@ -277,10 +277,11 @@ string FileName::toFilesystemEncoding() const
 }
 
 
-string FileName::toSafeFilesystemEncoding() const
+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()));
+       QString const safe_path =
+               toqstr(os::safe_internal_path(absFileName(), how));
        QByteArray const encoded = QFile::encodeName(safe_path);
        return string(encoded.begin(), encoded.end());
 }
@@ -496,12 +497,12 @@ unsigned long FileName::checksum() const
        unsigned long result = 0;
 
        if (!exists()) {
-               //LYXERR0("File \"" << absFilename() << "\" does not exist!");
+               //LYXERR0("File \"" << absFileName() << "\" does not exist!");
                return result;
        }
        // a directory may be passed here so we need to test it. (bug 3622)
        if (isDirectory()) {
-               LYXERR0('"' << absFilename() << "\" is a directory!");
+               LYXERR0('"' << absFileName() << "\" is a directory!");
                return result;
        }
 
@@ -578,7 +579,7 @@ unsigned long FileName::checksum() const
  #endif // SUM_WITH_MMAP
 #endif // QT_VERSION
 
-       LYXERR(Debug::FILES, "Checksumming \"" << absFilename() << "\" "
+       LYXERR(Debug::FILES, "Checksumming \"" << absFileName() << "\" "
                << result << " lasted " << t.elapsed() << " ms.");
        return result;
 }
@@ -699,7 +700,7 @@ docstring const FileName::absoluteFilePath() const
 
 docstring FileName::displayName(int threshold) const
 {
-       return makeDisplayPath(absFilename(), threshold);
+       return makeDisplayPath(absFileName(), threshold);
 }
 
 
@@ -742,7 +743,7 @@ docstring FileName::fileContents(string const & encoding) const
 void FileName::changeExtension(string const & extension)
 {
        // FIXME: use Qt native methods...
-       string const oldname = absFilename();
+       string const oldname = absFileName();
        string::size_type const last_slash = oldname.rfind('/');
        string::size_type last_dot = oldname.rfind('.');
        if (last_dot < last_slash && last_slash != string::npos)
@@ -965,8 +966,8 @@ bool equivalent(FileName const & l, FileName const & r)
        // * Long and short file names that refer to the same file on Windows are
        //   treated as if they referred to different files.
        // This is supposed to be fixed for Qt5.
-       FileName const lhs(os::internal_path(l.absFilename()));
-       FileName const rhs(os::internal_path(r.absFilename()));
+       FileName const lhs(os::internal_path(l.absFileName()));
+       FileName const rhs(os::internal_path(r.absFileName()));
 
        if (lhs.empty())
                // QFileInfo::operator==() returns false if the two QFileInfo are empty.
@@ -1001,9 +1002,9 @@ bool equivalent(FileName const & l, FileName const & r)
 bool operator==(FileName const & lhs, FileName const & rhs)
 {
        return os::isFilesystemCaseSensitive()
-               ? lhs.absFilename() == rhs.absFilename()
-               : !QString::compare(toqstr(lhs.absFilename()),
-                               toqstr(rhs.absFilename()), Qt::CaseInsensitive);
+               ? lhs.absFileName() == rhs.absFileName()
+               : !QString::compare(toqstr(lhs.absFileName()),
+                               toqstr(rhs.absFileName()), Qt::CaseInsensitive);
 }
 
 
@@ -1015,19 +1016,19 @@ bool operator!=(FileName const & lhs, FileName const & rhs)
 
 bool operator<(FileName const & lhs, FileName const & rhs)
 {
-       return lhs.absFilename() < rhs.absFilename();
+       return lhs.absFileName() < rhs.absFileName();
 }
 
 
 bool operator>(FileName const & lhs, FileName const & rhs)
 {
-       return lhs.absFilename() > rhs.absFilename();
+       return lhs.absFileName() > rhs.absFileName();
 }
 
 
 ostream & operator<<(ostream & os, FileName const & filename)
 {
-       return os << filename.absFilename();
+       return os << filename.absFileName();
 }
 
 
@@ -1059,7 +1060,7 @@ void DocFileName::set(string const & name, string const & buffer_path)
        if (save_abs_path_)
                FileName::set(name);
        else
-               FileName::set(makeAbsPath(name, buffer_path).absFilename());
+               FileName::set(makeAbsPath(name, buffer_path).absFileName());
        zipped_valid_ = false;
 }
 
@@ -1071,30 +1072,30 @@ void DocFileName::erase()
 }
 
 
-string DocFileName::relFilename(string const & path) const
+string DocFileName::relFileName(string const & path) const
 {
        // FIXME UNICODE
        return to_utf8(relPath(path));
 }
 
 
-string DocFileName::outputFilename(string const & path) const
+string DocFileName::outputFileName(string const & path) const
 {
-       return save_abs_path_ ? absFilename() : relFilename(path);
+       return save_abs_path_ ? absFileName() : relFileName(path);
 }
 
 
-string DocFileName::mangledFilename(string const & dir) const
+string DocFileName::mangledFileName(string const & dir) const
 {
        // We need to make sure that every DocFileName instance for a given
        // filename returns the same mangled name.
        typedef map<string, string> MangledMap;
        static MangledMap mangledNames;
-       MangledMap::const_iterator const it = mangledNames.find(absFilename());
+       MangledMap::const_iterator const it = mangledNames.find(absFileName());
        if (it != mangledNames.end())
                return (*it).second;
 
-       string const name = absFilename();
+       string const name = absFileName();
        // Now the real work
        string mname = os::internal_path(name);
        // Remove the extension.
@@ -1108,7 +1109,7 @@ string DocFileName::mangledFilename(string const & dir) const
        // in the name.
        static string const keep = "abcdefghijklmnopqrstuvwxyz"
                                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                  "+,-0123456789;=";
+                                  "+-0123456789;=";
        string::size_type pos = 0;
        while ((pos = mname.find_first_not_of(keep, pos)) != string::npos)
                mname[pos++] = '_';
@@ -1141,7 +1142,7 @@ string DocFileName::mangledFilename(string const & dir) const
                }
        }
 
-       mangledNames[absFilename()] = mname;
+       mangledNames[absFileName()] = mname;
        return mname;
 }
 
@@ -1156,9 +1157,9 @@ bool DocFileName::isZipped() const
 }
 
 
-string DocFileName::unzippedFilename() const
+string DocFileName::unzippedFileName() const
 {
-       return unzippedFileName(absFilename());
+       return support::unzippedFileName(absFileName());
 }