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

Method SetPermissions

Source/cmFileCopier.cxx:66–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66bool 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.
102bool cmFileCopier::CheckPermissions(std::string const& arg,

Callers 2

InstallFileMethod · 0.95
InstallDirectoryMethod · 0.95

Calls 8

SetPermissionsFunction · 0.85
c_strMethod · 0.80
strMethod · 0.80
IsOnMethod · 0.45
closeMethod · 0.45
StoreMethod · 0.45
GetStringMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected