| 28 | const DateTime UnixEpoch(1970, 1, 1); |
| 29 | |
| 30 | bool UnixFileSystem::CreateDirectory(const StringView& path) |
| 31 | { |
| 32 | const UnixString pathAnsi(*path, path.Length()); |
| 33 | |
| 34 | // Skip if already exists |
| 35 | struct stat fileInfo; |
| 36 | if (stat(pathAnsi.Get(), &fileInfo) != -1 && S_ISDIR(fileInfo.st_mode)) |
| 37 | { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | // Recursively do it all again for the parent directory, if any |
| 42 | const int32 slashIndex = path.FindLast('/'); |
| 43 | if (slashIndex > 1) |
| 44 | { |
| 45 | if (CreateDirectory(path.Substring(0, slashIndex))) |
| 46 | { |
| 47 | return true; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Create the last directory on the path (the recursive calls will have taken care of the parent directories by now) |
| 52 | return mkdir(pathAnsi.Get(), 0755) != 0 && errno != EEXIST; |
| 53 | } |
| 54 | |
| 55 | #if HAS_DIRS |
| 56 |
no test coverage detected