add FileName::renameTo() method.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22117 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-13 07:36:47 +00:00
parent 6b8cd3a7cd
commit 15fe6b3c53
2 changed files with 14 additions and 0 deletions

View File

@ -139,6 +139,15 @@ bool FileName::copyTo(FileName const & name, bool overwrite) const
} }
bool FileName::renameTo(FileName const & name) const
{
bool success = QFile::rename(d->fi.absoluteFilePath(), name.d->fi.absoluteFilePath());
if (!success)
LYXERR0("Could not copy file " << *this << " to " << name);
return success;
}
string FileName::toFilesystemEncoding() const string FileName::toFilesystemEncoding() const
{ {
QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath()); QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath());

View File

@ -98,6 +98,11 @@ public:
/// \retrun true on success. /// \retrun true on success.
bool removeFile() const; bool removeFile() const;
/// rename pointed file.
/// \retrun true on success.
bool renameTo(FileName const & target) const;
/// remove directory and all contents, returns true on success /// remove directory and all contents, returns true on success
bool destroyDirectory() const; bool destroyDirectory() const;
/// Creates directory. Returns true on success /// Creates directory. Returns true on success