mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Change semantics of FileName::copyTo(): we now overwrite the target file unconditionally.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22159 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c817011cd8
commit
1948c5812c
@ -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"),
|
||||
|
@ -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."),
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 << "'"
|
||||
|
@ -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"
|
||||
|
@ -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 "
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user