The rename() function removed in rev had in fact move() functionality. So we replace all uses of renameTo() with the new FileName::moveTo() method.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22149 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-14 18:16:25 +00:00
parent 77ac196f64
commit d1574fec83
5 changed files with 23 additions and 4 deletions

View File

@ -845,7 +845,7 @@ bool Buffer::save() const
} else {
// Saving failed, so backup is not backup
if (madeBackup)
backupName.renameTo(d->filename);
backupName.moveTo(d->filename);
return false;
}
}
@ -1926,7 +1926,7 @@ int AutoSaveBuffer::generateChild()
if (!tmp_ret.empty()) {
buffer_.writeFile(tmp_ret);
// assume successful write of tmp_ret
if (!tmp_ret.renameTo(fname_)) {
if (!tmp_ret.moveTo(fname_)) {
failed = true;
// most likely couldn't move between
// filesystems unless write of tmp_ret

View File

@ -49,7 +49,7 @@ bool Mover::rename(FileName const & from,
bool Mover::do_rename(FileName const & from, FileName const & to,
string const &) const
{
return from.renameTo(to);
return from.moveTo(to);
}

View File

@ -688,7 +688,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
// the file format from the extension, so we must
// change it.
FileName const new_file = FileName(changeExtension(temp_file.absFilename(), ext));
if (temp_file.renameTo(new_file)) {
if (temp_file.moveTo(new_file)) {
temp_file = new_file;
output_file = changeExtension(output_file, ext);
source_file = FileName(changeExtension(source_file.absFilename(), ext));

View File

@ -150,6 +150,19 @@ bool FileName::renameTo(FileName const & name) const
}
bool FileName::moveTo(FileName const & name) const
{
if (name.exists() && !name.removeFile())
return false;
bool success = QFile::rename(d->fi.absoluteFilePath(),
name.d->fi.absoluteFilePath());
if (!success)
LYXERR0("Could not move file " << *this << " to " << name);
return success;
}
bool FileName::changePermission(unsigned long int mode) const
{
if (!isWritable()) {

View File

@ -99,9 +99,15 @@ public:
bool removeFile() const;
/// rename pointed file.
/// \return false if the operation fails or if the \param target file
/// already exists.
/// \return true on success.
bool renameTo(FileName const & target) const;
/// move pointed file to \param target.
/// \return true on success.
bool moveTo(FileName const & target) const;
/// change mode of pointed file.
/// This methods does nothing and return true on platforms that does not
/// support this.