]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
zipunzip.cpp: Replace makedir etc with versions in support::FileName, fix a bug in...
[lyx.git] / src / support / FileName.cpp
index f3e73a8bc4dbec8184084be7d9825ae526f058df..e847ecc5a2ace72d7073febeb51644fb4e69e23d 100644 (file)
@@ -17,7 +17,6 @@
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
-#include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/Package.h"
 #include "support/qstring_helpers.h"
@@ -141,6 +140,12 @@ bool FileName::empty() const
 }
 
 
+bool FileName::isAbsolute() const
+{
+       return d->fi.isAbsolute();
+}
+
+
 string FileName::absFilename() const
 {
        return fromqstr(d->fi.absoluteFilePath());
@@ -150,7 +155,6 @@ string FileName::absFilename() const
 void FileName::set(string const & name)
 {
        d->fi.setFile(toqstr(name));
-       BOOST_ASSERT(d->fi.isAbsolute());
 }
 
 
@@ -194,11 +198,6 @@ bool FileName::moveTo(FileName const & name) const
 
 bool FileName::changePermission(unsigned long int mode) const
 {
-       if (!isWritable()) {
-               LYXERR0("File " << *this << " is not writable!");
-               return false;
-       }
-
 #if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
        if (::chmod(toFilesystemEncoding().c_str(), mode_t(mode)) != 0) {
                LYXERR0("File " << *this << ": cannot change permission to "
@@ -262,13 +261,15 @@ bool FileName::isReadableDirectory() const
 
 string FileName::onlyFileName() const
 {
-       return support::onlyFilename(absFilename());
+       return fromqstr(d->fi.fileName());
 }
 
 
 FileName FileName::onlyPath() const
 {
-       return FileName(support::onlyPath(absFilename()));
+       FileName path;
+       path.d->fi.setFile(d->fi.path());
+       return path;
 }
 
 
@@ -399,6 +400,12 @@ FileName FileName::tempName(string const & mask)
 }
 
 
+FileName FileName::getcwd()
+{
+       return FileName(".");
+}
+
+
 time_t FileName::lastModified() const
 {
        return d->fi.lastModified().toTime_t();
@@ -416,7 +423,7 @@ extern unsigned long sum(char const * file);
 unsigned long FileName::checksum() const
 {
        if (!exists()) {
-               LYXERR0("File \"" << absFilename() << "\" does not exist!");
+               //LYXERR0("File \"" << absFilename() << "\" does not exist!");
                return 0;
        }
        // a directory may be passed here so we need to test it. (bug 3622)
@@ -846,8 +853,9 @@ DocFileName::DocFileName(FileName const & abs_filename, bool save_abs)
 
 void DocFileName::set(string const & name, string const & buffer_path)
 {
-       save_abs_path_ = absolutePath(name);
-       FileName::set(save_abs_path_ ? name : makeAbsPath(name, buffer_path).absFilename());
+       FileName::set(name);
+       if (!isAbsolute())
+               FileName::set(makeAbsPath(name, buffer_path).absFilename());
        zipped_valid_ = false;
 }