diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-13 17:50:06 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-18 14:09:10 (GMT) |
commit | 103aa9e46a5a59dc2c41cc1fa1aa6dd406b2924b (patch) | |
tree | 3a6293db032850cbc5d17d20965d2e3b68c4d15f /Source/cmFileTimeComparison.h | |
parent | 6f24c4e93f6ae897b793f894b67543d86c7de477 (diff) | |
download | CMake-103aa9e46a5a59dc2c41cc1fa1aa6dd406b2924b.zip CMake-103aa9e46a5a59dc2c41cc1fa1aa6dd406b2924b.tar.gz CMake-103aa9e46a5a59dc2c41cc1fa1aa6dd406b2924b.tar.bz2 |
cmFileTimeComparison: Use cmFileTime internally
This replaces OS dependent code in `cmFileTimeComparison` with `cmFileTime`
instances that provide the required file time load and comparison operations.
A new public `cmFileTimeComparison::Load` method is introduced that,
for a given file name, updates the `cmFileTimeComparison` cache on demand and
returns a `cmFileTime` instance on success.
Diffstat (limited to 'Source/cmFileTimeComparison.h')
-rw-r--r-- | Source/cmFileTimeComparison.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h index b4e4eb3..cc321f0 100644 --- a/Source/cmFileTimeComparison.h +++ b/Source/cmFileTimeComparison.h @@ -5,14 +5,13 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmFileTime.h" #include <string> class cmFileTimeComparisonInternal; /** \class cmFileTimeComparison - * \brief Helper class for comparing file modification times. - * - * Compare file modification times or test if file modification times differ. + * \brief Caches file modification times in an internal map for fast lookups. */ class cmFileTimeComparison { @@ -24,19 +23,27 @@ public: cmFileTimeComparison& operator=(const cmFileTimeComparison&) = delete; /** - * Compare file modification times. - * Return true for successful comparison and false for error. - * When true is returned, result has -1, 0, +1 for - * f1 older, same, or newer than f2. + * @brief Loads the file time from the cache or the file system. + * @return true on success */ - bool FileTimeCompare(const std::string& f1, const std::string& f2, + bool Load(std::string const& fileName, cmFileTime& fileTime); + + /** + * @brief Compare file modification times. + * @return true for successful comparison and false for error. + * + * When true is returned, result has -1, 0, +1 for + * f1 older, same, or newer than f2. + */ + bool FileTimeCompare(std::string const& f1, std::string const& f2, int* result); /** - * Compare file modification times. Return true unless both files - * exist and have modification times less than 1 second apart. + * @brief Compare file modification times. + * @return true unless both files exist and have modification times less + * than 1 second apart. */ - bool FileTimesDiffer(const std::string& f1, const std::string& f2); + bool FileTimesDiffer(std::string const& f1, std::string const& f2); protected: cmFileTimeComparisonInternal* Internals; |