]> git.lyx.org Git - lyx.git/blobdiff - src/EmbeddedFiles.cpp
Move Dialog.{h,cpp} and ButtonPolicy.{h,cpp} to frontends/qt4/
[lyx.git] / src / EmbeddedFiles.cpp
index abc9eaf8330609be86987bbbab5cd94ddd6669ca..63d0dcd811c031166fe7cbb83d4e0c4a8f55e9a8 100644 (file)
@@ -132,11 +132,14 @@ bool EmbeddedFile::extract(Buffer const * buf) const
        string ext_file = absFilename();
        string emb_file = embeddedFile(buf);
 
-       if (!fs::exists(emb_file))
+       FileName emb(emb_file);
+       FileName ext(ext_file);
+
+       if (!emb.exists())
                return false;
 
        // if external file already exists ...
-       if (fs::exists(ext_file)) {
+       if (ext.exists()) {
                // no need to copy if the files are the same
                if (sum(*this) == sum(FileName(emb_file)))
                        return true;
@@ -156,15 +159,13 @@ bool EmbeddedFile::extract(Buffer const * buf) const
        string path = support::onlyPath(ext_file);
        if (!fs::is_directory(path))
                makedir(const_cast<char*>(path.c_str()), 0755);
-       FileName emb(emb_file);
-       FileName ext(ext_file);
        if (emb.copyTo(ext, false))
                return true;
        Alert::error(_("Copy file failure"),
                 bformat(_("Cannot copy file %1$s to %2$s.\n"
                                 "Please check whether the directory exists and is writeable."),
                                from_utf8(emb_file), from_utf8(ext_file)));
-       //LYXERR(Debug::DEBUG) << "Fs error: " << fe.what() << endl;
+       //LYXERR(Debug::DEBUG, "Fs error: " << fe.what());
        return false;
 }
 
@@ -174,11 +175,14 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
        string ext_file = absFilename();
        string emb_file = embeddedFile(buf);
 
-       if (!fs::exists(ext_file))
+       FileName emb(emb_file);
+       FileName ext(ext_file);
+
+       if (!ext.exists())
                return false;
        
        // if embedded file already exists ...
-       if (fs::exists(emb_file)) {
+       if (emb.exists()) {
                // no need to copy if the files are the same
                if (sum(*this) == sum(FileName(emb_file)))
                        return true;
@@ -193,8 +197,6 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
                        return true;
        }
        // copy file
-       FileName emb(emb_file);
-       FileName ext(ext_file);
        // need to make directory?
        string path = support::onlyPath(emb_file);
        if (!fs::is_directory(path))
@@ -205,7 +207,7 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
                 bformat(_("Cannot copy file %1$s to %2$s.\n"
                           "Please check whether the directory exists and is writeable."),
                                from_utf8(ext_file), from_utf8(emb_file)));
-       //LYXERR(Debug::DEBUG) << "Fs error: " << fe.what() << endl;
+       //LYXERR(Debug::DEBUG, "Fs error: " << fe.what());
        return false;
 }
 
@@ -307,7 +309,7 @@ bool EmbeddedFiles::writeFile(DocFileName const & filename)
                                 bformat(_("Cannot create file %1$s.\n"
                                           "Please check whether the directory exists and is writeable."),
                                         from_utf8(filename.absFilename())));
-               //LYXERR(Debug::DEBUG) << "Fs error: " << fe.what() << endl;
+               //LYXERR(Debug::DEBUG, "Fs error: " << fe.what());
        }
        return true;
 }