| 290 | } |
| 291 | |
| 292 | bool KittyIOFile::createDirectoryRecursive(const std::string &path, mode_t mode) |
| 293 | { |
| 294 | if (path.empty()) |
| 295 | return false; |
| 296 | |
| 297 | std::string current; |
| 298 | size_t pos = 0; |
| 299 | |
| 300 | // Handle absolute paths |
| 301 | if (path[0] == '/') |
| 302 | { |
| 303 | current = "/"; |
| 304 | pos = 1; |
| 305 | } |
| 306 | |
| 307 | while (pos <= path.size()) |
| 308 | { |
| 309 | size_t next = path.find('/', pos); |
| 310 | std::string part = path.substr(pos, next - pos); |
| 311 | |
| 312 | if (!part.empty()) |
| 313 | { |
| 314 | // Append next path component |
| 315 | if (!current.empty() && current.back() != '/') |
| 316 | current += "/"; |
| 317 | |
| 318 | current += part; |
| 319 | |
| 320 | // Attempt to create directory |
| 321 | if (mkdir(current.c_str(), mode) != 0) |
| 322 | { |
| 323 | if (errno != EEXIST) |
| 324 | { |
| 325 | return false; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | if (next == std::string::npos) |
| 331 | break; |
| 332 | |
| 333 | pos = next + 1; |
| 334 | } |
| 335 | |
| 336 | return true; |
| 337 | } |
nothing calls this directly
no outgoing calls
no test coverage detected