| 106 | } |
| 107 | |
| 108 | cmsys::Status cmFileTimes::Store(std::string const& fileName) const |
| 109 | { |
| 110 | if (!this->IsValid()) { |
| 111 | return cmsys::Status::POSIX(EINVAL); |
| 112 | } |
| 113 | |
| 114 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 115 | cmFileTimes::WindowsHandle handle = CreateFileW( |
| 116 | cmSystemTools::ConvertToWindowsExtendedPath(fileName).c_str(), |
| 117 | FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); |
| 118 | if (!handle) { |
| 119 | return cmsys::Status::Windows_GetLastError(); |
| 120 | } |
| 121 | if (SetFileTime(handle, &this->times->timeCreation, |
| 122 | &this->times->timeLastAccess, |
| 123 | &this->times->timeLastWrite) == 0) { |
| 124 | return cmsys::Status::Windows_GetLastError(); |
| 125 | } |
| 126 | #else |
| 127 | if (utime(fileName.c_str(), &this->times->timeBuf) < 0) { |
| 128 | return cmsys::Status::POSIX_errno(); |
| 129 | } |
| 130 | #endif |
| 131 | return cmsys::Status::Success(); |
| 132 | } |
| 133 | |
| 134 | cmsys::Status cmFileTimes::Copy(std::string const& fromFile, |
| 135 | std::string const& toFile) |
no test coverage detected