cmFileTimes.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmFileTimes_h
  4. #define cmFileTimes_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <memory>
  7. #include <string>
  8. /** \class cmFileTimes
  9. * \brief Loads and stores file times.
  10. */
  11. class cmFileTimes
  12. {
  13. public:
  14. cmFileTimes();
  15. //! Calls Load()
  16. cmFileTimes(std::string const& fileName);
  17. ~cmFileTimes();
  18. //! @return true, if file times were loaded successfully
  19. bool IsValid() const { return (times != nullptr); }
  20. //! Try to load the file times from @a fileName and @return IsValid()
  21. bool Load(std::string const& fileName);
  22. //! Stores the file times at @a fileName (if IsValid())
  23. bool Store(std::string const& fileName) const;
  24. //! Copies the file times of @a fromFile to @a toFile
  25. static bool Copy(std::string const& fromFile, std::string const& toFile);
  26. private:
  27. #ifdef _WIN32
  28. class WindowsHandle;
  29. #endif
  30. class Times;
  31. std::unique_ptr<Times> times;
  32. };
  33. #endif