| 64 | } |
| 65 | |
| 66 | bool cmFileCopier::SetPermissions(std::string const& toFile, |
| 67 | mode_t permissions) |
| 68 | { |
| 69 | if (permissions) { |
| 70 | #ifdef _WIN32 |
| 71 | if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) { |
| 72 | // Store the mode in an NTFS alternate stream. |
| 73 | std::string mode_t_adt_filename = toFile + ":cmake_mode_t"; |
| 74 | |
| 75 | // Writing to an NTFS alternate stream changes the modification |
| 76 | // time, so we need to save and restore its original value. |
| 77 | cmFileTimes file_time_orig(toFile); |
| 78 | { |
| 79 | cmsys::ofstream permissionStream(mode_t_adt_filename.c_str()); |
| 80 | if (permissionStream) { |
| 81 | permissionStream << std::oct << permissions << std::endl; |
| 82 | } |
| 83 | permissionStream.close(); |
| 84 | } |
| 85 | file_time_orig.Store(toFile); |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | auto perm_status = cmSystemTools::SetPermissions(toFile, permissions); |
| 90 | if (!perm_status) { |
| 91 | std::ostringstream e; |
| 92 | e << this->Name << " cannot set permissions on \"" << toFile |
| 93 | << "\": " << perm_status.GetString() << "."; |
| 94 | this->Status.SetError(e.str()); |
| 95 | return false; |
| 96 | } |
| 97 | } |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | // Translate an argument to a permissions bit. |
| 102 | bool cmFileCopier::CheckPermissions(std::string const& arg, |