| 254 | } |
| 255 | |
| 256 | std::string getFirstPathSegment(const std::string& path) { |
| 257 | if (path.empty()) { |
| 258 | return path; |
| 259 | } |
| 260 | auto start_index = path[0] == SEPARATOR ? 1 : 0; |
| 261 | auto index = path.find_first_of(SEPARATOR, start_index); |
| 262 | if (index != std::string::npos) { |
| 263 | return path.substr(0, index); |
| 264 | } else { |
| 265 | return path; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | bool findOrCreateDirectory(const std::string& path, mode_t mode) { |
| 270 | if (path.empty()) { |