]> git.lyx.org Git - features.git/commitdiff
Change semantics of FileName::copyTo(): we now overwrite the target file unconditionally.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 15 Dec 2007 08:25:53 +0000 (08:25 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 15 Dec 2007 08:25:53 +0000 (08:25 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22159 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/EmbeddedFiles.cpp
src/Mover.cpp
src/insets/InsetBibtex.cpp
src/insets/InsetInclude.cpp
src/support/FileName.cpp
src/support/FileName.h

index 7ea74bdb22ac674d166c19f2f88c9696069d1773..f218e9904932ea484930bc728b1985b52f7638c4 100644 (file)
@@ -817,7 +817,7 @@ bool Buffer::save() const
                        backupName = FileName(addName(lyxrc.backupdir_path,
                                                      mangledName));
                }
-               if (fileName().copyTo(backupName, true)) {
+               if (fileName().copyTo(backupName)) {
                        madeBackup = true;
                } else {
                        Alert::error(_("Backup failure"),
index d8756b1d9ed3adb3aff0883d7e66b3ebad02af98..6c6fffec4de6f4234604bd33c36c43b78c34e53c 100644 (file)
@@ -142,7 +142,7 @@ bool EmbeddedFile::extract(Buffer const * buf) const
                return false;
        }
 
-       if (emb.copyTo(ext, true))
+       if (emb.copyTo(ext))
                return true;
 
        Alert::error(_("Copy file failure"),
@@ -184,7 +184,7 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
        FileName path = emb.onlyPath();
        if (!path.isDirectory())
                path.createPath();
-       if (ext.copyTo(emb, true))
+       if (ext.copyTo(emb))
                return true;
        Alert::error(_("Copy file failure"),
                 bformat(_("Cannot copy file %1$s to %2$s.\n"
@@ -287,7 +287,7 @@ bool EmbeddedFiles::writeFile(DocFileName const & filename)
 
        ::zipFiles(zipfile.toFilesystemEncoding(), filenames);
        // copy file back
-       if (!zipfile.copyTo(filename, true)) {
+       if (!zipfile.copyTo(filename)) {
                Alert::error(_("Save failure"),
                                 bformat(_("Cannot create file %1$s.\n"
                                           "Please check whether the directory exists and is writeable."),
index 28f2ce950a9f25f32e832618f4a4d4b31eb4760a..990a550cb690083d7be1336274c10ba9697a3fd6 100644 (file)
@@ -35,7 +35,7 @@ bool Mover::copy(FileName const & from, FileName const & to) const
 bool Mover::do_copy(FileName const & from, FileName const & to,
                    string const &) const
 {
-       return from.copyTo(to, true);
+       return from.copyTo(to);
 }
 
 
index 23be923ad0fce45cad36e13c6ae0db69708d280c..9f9d21398a5e1dbb7c95332a8ff3bec7d8b32d68 100644 (file)
@@ -179,7 +179,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
                        FileName const out_file = makeAbsPath(database + ".bib",
                                        buffer.masterBuffer()->temppath());
 
-                       bool const success = in_file.copyTo(out_file, true);
+                       bool const success = in_file.copyTo(out_file);
                        if (!success) {
                                lyxerr << "Failed to copy '" << in_file
                                       << "' to '" << out_file << "'"
@@ -238,7 +238,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
                        base = removeExtension(in_file.mangledFilename());
                        FileName const out_file(makeAbsPath(base + ".bst",
                                        buffer.masterBuffer()->temppath()));
-                       bool const success = in_file.copyTo(out_file, true);
+                       bool const success = in_file.copyTo(out_file);
                        if (!success) {
                                lyxerr << "Failed to copy '" << in_file
                                       << "' to '" << out_file << "'"
index a9838547151d6d6030a822d3beecb7dc1fcacbff..b6a4f0bc6d2756e2cf3dd8550a087ab62b547e55 100644 (file)
@@ -475,7 +475,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
                unsigned long const checksum_out = writefile.checksum();
 
                if (checksum_in != checksum_out) {
-                       if (!included_file.copyTo(writefile, true)) {
+                       if (!included_file.copyTo(writefile)) {
                                // FIXME UNICODE
                                LYXERR(Debug::LATEX,
                                        to_utf8(bformat(_("Could not copy the file\n%1$s\n"
index e0e10cf07f8a2905c08223b790979c43d3f9e27e..1b4a545f3f088e7d01974dfc737feef9862efd41 100644 (file)
@@ -139,10 +139,9 @@ void FileName::erase()
 }
 
 
-bool FileName::copyTo(FileName const & name, bool overwrite) const
+bool FileName::copyTo(FileName const & name) const
 {
-       if (overwrite)
-               QFile::remove(name.d->fi.absoluteFilePath());
+       QFile::remove(name.d->fi.absoluteFilePath());
        bool success = QFile::copy(d->fi.absoluteFilePath(), name.d->fi.absoluteFilePath());
        if (!success)
                lyxerr << "FileName::copyTo(): Could not copy file "
index fd63ce5e5374f3100b16686c159a2b673a53b7c4..dd3932a2dde336e678dc095d971cdfb6f39e6d3c 100644 (file)
@@ -90,9 +90,9 @@ public:
        
        /// copy a file
        /// \return true when file/directory is writable (write test file)
-       /// \param overwrite: set to true if we should erase the \c target 
-       /// file if it exists,
-       bool copyTo(FileName const & target, bool overwrite = false) const;
+       /// \warning This methods has different semantics when system level
+       /// copy command, it will overwrite the \c target file if it exists,
+       bool copyTo(FileName const & target) const;
 
        /// remove pointed file.
        /// \return true on success.