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

Method Restore

Source/cmSystemTools.cxx:1283–1312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1281}
1282
1283bool FileModeGuard::Restore(std::string* emsg)
1284{
1285 assert(filepath_.empty() == false);
1286
1287#ifndef _WIN32
1288 struct stat file_stat;
1289 if (stat(filepath_.c_str(), &file_stat) != 0) {
1290 if (emsg) {
1291 *emsg = cmStrCat("Cannot get file stat: ", strerror(errno));
1292 }
1293 return false;
1294 }
1295
1296 // Nothing changed; everything is in the expected state
1297 if (file_stat.st_mode == mode_) {
1298 return true;
1299 }
1300
1301 if (chmod(filepath_.c_str(), mode_) != 0) {
1302 if (emsg) {
1303 *emsg = cmStrCat("Cannot restore the file mode: ", strerror(errno));
1304 }
1305 return false;
1306 }
1307#else
1308 static_cast<void>(emsg);
1309#endif
1310
1311 return true;
1312}
1313
1314bool FileModeGuard::HasErrors() const
1315{

Callers 3

AdjustRPathELFFunction · 0.80
RemoveRPathELFFunction · 0.80
RemoveRPathXCOFFFunction · 0.80

Calls 4

c_strMethod · 0.80
statClass · 0.70
cmStrCatFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected