diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-21 21:36:40 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-22 08:57:10 (GMT) |
commit | 4b45a5d5c7f9266e5ca08f6d5676759b9aac4235 (patch) | |
tree | e5f2e186a1492544eed21587aeb796ad713fbb52 /Source/cmFileTimes.h | |
parent | 0bf53483295a4b7de358e8b85ad44866d89633c5 (diff) | |
download | CMake-4b45a5d5c7f9266e5ca08f6d5676759b9aac4235.zip CMake-4b45a5d5c7f9266e5ca08f6d5676759b9aac4235.tar.gz CMake-4b45a5d5c7f9266e5ca08f6d5676759b9aac4235.tar.bz2 |
cmFileTimes: New RAII based cmFileTimes class
This adds a new RAII based cmFileTimes class.
It is supposed to replace the C style cmSystemToolsFileTime interface.
Diffstat (limited to 'Source/cmFileTimes.h')
-rw-r--r-- | Source/cmFileTimes.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/cmFileTimes.h b/Source/cmFileTimes.h new file mode 100644 index 0000000..cbf0fe2 --- /dev/null +++ b/Source/cmFileTimes.h @@ -0,0 +1,40 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmFileTimes_h +#define cmFileTimes_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <memory> // IWYU pragma: keep +#include <string> + +/** \class cmFileTimes + * \brief Loads and stores file times. + */ +class cmFileTimes +{ +public: + cmFileTimes(); + //! Calls Load() + cmFileTimes(std::string const& fileName); + ~cmFileTimes(); + + //! @return true, if file times were loaded successfully + bool IsValid() const { return (times != nullptr); } + //! Try to load the file times from @a fileName and @return IsValid() + bool Load(std::string const& fileName); + //! Stores the file times at @a fileName (if IsValid()) + bool Store(std::string const& fileName) const; + + //! Copies the file times of @a fromFile to @a toFile + static bool Copy(std::string const& fromFile, std::string const& toFile); + +private: +#ifdef _WIN32 + class WindowsHandle; +#endif + class Times; + std::unique_ptr<Times> times; +}; + +#endif |