MCPcopy Create free account
hub / github.com/Kitware/CMake / Load

Method Load

Source/cmFileTimes.cxx:73–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71cmFileTimes::~cmFileTimes() = default;
72
73cmsys::Status cmFileTimes::Load(std::string const& fileName)
74{
75 std::unique_ptr<Times> ptr;
76 if (this->IsValid()) {
77 // Invalidate this and reuse times
78 ptr.swap(this->times);
79 } else {
80 ptr = cm::make_unique<Times>();
81 }
82
83#if defined(_WIN32) && !defined(__CYGWIN__)
84 cmFileTimes::WindowsHandle handle =
85 CreateFileW(cmSystemTools::ConvertToWindowsExtendedPath(fileName).c_str(),
86 GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING,
87 FILE_FLAG_BACKUP_SEMANTICS, 0);
88 if (!handle) {
89 return cmsys::Status::Windows_GetLastError();
90 }
91 if (!GetFileTime(handle, &ptr->timeCreation, &ptr->timeLastAccess,
92 &ptr->timeLastWrite)) {
93 return cmsys::Status::Windows_GetLastError();
94 }
95#else
96 struct stat st;
97 if (stat(fileName.c_str(), &st) < 0) {
98 return cmsys::Status::POSIX_errno();
99 }
100 ptr->timeBuf.actime = st.st_atime;
101 ptr->timeBuf.modtime = st.st_mtime;
102#endif
103 // Accept times
104 this->times = std::move(ptr);
105 return cmsys::Status::Success();
106}
107
108cmsys::Status cmFileTimes::Store(std::string const& fileName) const
109{

Callers 2

cmFileTimesMethod · 0.95
CopyMethod · 0.45

Calls 5

IsValidMethod · 0.95
moveFunction · 0.85
c_strMethod · 0.80
statClass · 0.70
swapMethod · 0.45

Tested by

no test coverage detected