]> git.lyx.org Git - lyx.git/commitdiff
add FileName::renameTo() method.
authorAbdelrazak Younes <younes@lyx.org>
Thu, 13 Dec 2007 07:36:47 +0000 (07:36 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 13 Dec 2007 07:36:47 +0000 (07:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22117 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/FileName.cpp
src/support/FileName.h

index be33fe0f060a2057d3e16ec998e34103f30bb245..110b44711d8f609cacc698818326fffaf85a0bce 100644 (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
 {
        QByteArray const encoded = QFile::encodeName(d->fi.absoluteFilePath());
index c293f66021fada455cd4ad35df7cabf2aba3d827..328602bf34e692aaa968e9def85116ff5ceeb767 100644 (file)
@@ -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