| 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 | { |