From 15fe6b3c535d15347973041aeac0512fcdce1a9c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 13 Dec 2007 07:36:47 +0000 Subject: [PATCH] add FileName::renameTo() method. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22117 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/FileName.cpp | 9 +++++++++ src/support/FileName.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index be33fe0f06..110b44711d 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -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 { QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath()); diff --git a/src/support/FileName.h b/src/support/FileName.h index c293f66021..328602bf34 100644 --- a/src/support/FileName.h +++ b/src/support/FileName.h @@ -98,6 +98,11 @@ public: /// \retrun true on success. 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 bool destroyDirectory() const; /// Creates directory. Returns true on success