diff options
Diffstat (limited to 'qthelper.cpp')
-rw-r--r-- | qthelper.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index 6e3c957a6..3a4daf833 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -627,6 +627,28 @@ extern "C" const char *system_default_directory(void) return filename; } +extern "C" char *move_away(const char *old_path) +{ + if (verbose > 1) + qDebug() << "move away" << old_path; + QFile oldFile(old_path); + QFile newFile; + QString newPath; + int i = 0; + do { + newPath = QString(old_path) + QString(".%1").arg(++i); + newFile.setFileName(newPath); + } while(newFile.exists()); + if (verbose > 1) + qDebug() << "renaming to" << newPath; + if (!oldFile.rename(newPath)) { + qDebug() << "rename of" << old_path << "to" << newPath << "failed"; + return strdup(""); + } + return strdup(qPrintable(newPath)); + +} + extern "C" char *get_file_name(const char *fileName) { QFileInfo fileInfo(fileName); |