MCPcopy Create free account
hub / github.com/covscript/covscript / parse_mode

Function parse_mode

sources/system/common.cpp:72–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 }
71
72 unsigned int parse_mode(const std::string &modeString)
73 {
74 const char *perm = modeString.c_str();
75 unsigned int mode = 0;
76
77 if (std::isdigit(perm[0])) {
78 const char *p = perm;
79 while (*p) {
80 mode = mode * 8 + *p++ - '0';
81 }
82 }
83 else {
84 if (modeString.size() == 9) {
85 mode = (((perm[0] == 'r') * 4 | (perm[1] == 'w') * 2 | (perm[2] == 'x')) << 6) |
86 (((perm[3] == 'r') * 4 | (perm[4] == 'w') * 2 | (perm[5] == 'x')) << 3) |
87 (((perm[6] == 'r') * 4 | (perm[7] == 'w') * 2 | (perm[8] == 'x')));
88 }
89 }
90 return mode;
91 }
92
93 static bool mkdir_dirs(const std::vector<std::string> &dirs, unsigned int mode, bool absolute_path = false)
94 {

Callers 2

chmod_rFunction · 0.85
chmodFunction · 0.85

Calls 2

isdigitFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected