diff options
-rw-r--r-- | src/libs/utils/fileutils.cpp | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 4821af16ae..9fa83185a7 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -53,57 +53,12 @@ namespace Utils { */ /*! - \fn Utils::FileUtils::removeRecursively(const QString &filePath, QString *error) - Removes the directory \a filePath and its subdirectories recursively. \note The \a error parameter is optional. \return Whether the operation succeeded. */ - -/*! - \fn Utils::FileUtils::copyRecursively(const QString &srcFilePath, const QString &tgtFilePath, QString *error) - - Copies the directory specified by \a srcFilePath recursively to \a tgtFilePath. \a tgtFilePath will contain - the target directory, which will be created. Example usage: - - \code - QString error; - book ok = Utils::FileUtils::copyRecursively("/foo/bar", "/foo/baz", &error); - if (!ok) - qDebug() << error; - \endcode - - This will copy the contents of /foo/bar into to the baz directory under /foo, which will be created in the process. - - \note The \a error parameter is optional. - - \return Whether the operation succeeded. -*/ - -/*! - \fn Utils::FileUtils::isFileNewerThan(const QString &filePath, const QDateTime &timeStamp) - - If \a filePath is a directory, the function will recursively check all files and return - true if one of them is newer than \a timeStamp. If \a filePath is a single file, true will - be returned if the file is newer than \timeStamp. - - \return Whether at least one file in \a filePath has a newer date than \a timeStamp. -*/ - -/*! - \fn Utils::FileUtils::resolveSymlinks(const QString &filePath) - - Recursively resolve possibly present symlinks in \a filePath. - Unlike QFileInfo::canonicalFilePath(), this function will still return the expected target file - even if the symlink is dangling. - - \note Maximum recursion depth == 16. - - return Symlink target file path. -*/ - bool FileUtils::removeRecursively(const QString &filePath, QString *error) { QFileInfo fileInfo(filePath); @@ -153,6 +108,23 @@ bool FileUtils::removeRecursively(const QString &filePath, QString *error) return true; } +/*! + Copies the directory specified by \a srcFilePath recursively to \a tgtFilePath. \a tgtFilePath will contain + the target directory, which will be created. Example usage: + + \code + QString error; + book ok = Utils::FileUtils::copyRecursively("/foo/bar", "/foo/baz", &error); + if (!ok) + qDebug() << error; + \endcode + + This will copy the contents of /foo/bar into to the baz directory under /foo, which will be created in the process. + + \note The \a error parameter is optional. + + \return Whether the operation succeeded. +*/ bool FileUtils::copyRecursively(const QString &srcFilePath, const QString &tgtFilePath, QString *error) { @@ -190,6 +162,13 @@ bool FileUtils::copyRecursively(const QString &srcFilePath, return true; } +/*! + If \a filePath is a directory, the function will recursively check all files and return + true if one of them is newer than \a timeStamp. If \a filePath is a single file, true will + be returned if the file is newer than \timeStamp. + + \return Whether at least one file in \a filePath has a newer date than \a timeStamp. +*/ bool FileUtils::isFileNewerThan(const QString &filePath, const QDateTime &timeStamp) { @@ -209,6 +188,15 @@ bool FileUtils::isFileNewerThan(const QString &filePath, return false; } +/*! + Recursively resolve possibly present symlinks in \a filePath. + Unlike QFileInfo::canonicalFilePath(), this function will still return the expected target file + even if the symlink is dangling. + + \note Maximum recursion depth == 16. + + return Symlink target file path. +*/ QString FileUtils::resolveSymlinks(const QString &path) { QFileInfo f(path); |