| 1263 | }; |
| 1264 | |
| 1265 | FileModeGuard::FileModeGuard(std::string const& file_path, std::string* emsg) |
| 1266 | { |
| 1267 | #ifndef _WIN32 |
| 1268 | struct stat file_stat; |
| 1269 | if (stat(file_path.c_str(), &file_stat) != 0) { |
| 1270 | if (emsg) { |
| 1271 | *emsg = cmStrCat("Cannot get file stat: ", strerror(errno)); |
| 1272 | } |
| 1273 | return; |
| 1274 | } |
| 1275 | |
| 1276 | mode_ = file_stat.st_mode; |
| 1277 | #else |
| 1278 | static_cast<void>(emsg); |
| 1279 | #endif |
| 1280 | filepath_ = file_path; |
| 1281 | } |
| 1282 | |
| 1283 | bool FileModeGuard::Restore(std::string* emsg) |
| 1284 | { |