]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
Introduce FileName::changePermission() and fix ConverterCache.
[lyx.git] / src / support / FileName.cpp
index be33fe0f060a2057d3e16ec998e34103f30bb245..63f13e23250247aa8a19a5edb0000946d4507d3c 100644 (file)
@@ -60,7 +60,9 @@ struct FileName::Private
        Private() {}
 
        Private(string const & abs_filename) : fi(toqstr(abs_filename))
-       {}
+       {
+               fi.setCaching(fi.exists() ? true : false);
+       }
        ///
        QFileInfo fi;
 };
@@ -139,6 +141,30 @@ bool FileName::copyTo(FileName const & name, bool overwrite) const
 }
 
 
+bool FileName::renameTo(FileName const & name) const
+{
+       bool success = QFile::rename(d->fi.absoluteFilePath(), name.d->fi.absoluteFilePath());
+       if (!success)
+               LYXERR0("Could not rename file " << *this << " to " << name);
+       return success;
+}
+
+
+bool FileName::changePermission(unsigned long int mode) const
+{
+       if (!fname.isWritable()) {
+               LYXERR0("File " << *this << " is not writable!");
+               return false;
+       }
+
+       if (!chmod(fname, mode)) {
+               LYXERR0("File " << *this << " cannot be changed to " << mode << " mode!");
+               return false;
+       }
+       return true;
+}
+
+
 string FileName::toFilesystemEncoding() const
 {
        QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath());