| 111 | } |
| 112 | |
| 113 | bool AndroidFileSystem::CreateDirectory(const StringView& path) |
| 114 | { |
| 115 | const StringAsANSI<> pathAnsi(*path, path.Length()); |
| 116 | |
| 117 | // Skip if already exists |
| 118 | struct stat fileInfo; |
| 119 | if (stat(pathAnsi.Get(), &fileInfo) != -1 && S_ISDIR(fileInfo.st_mode)) |
| 120 | { |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | // Recursively do it all again for the parent directory, if any |
| 125 | const int32 slashIndex = path.FindLast('/'); |
| 126 | if (slashIndex > 1) |
| 127 | { |
| 128 | if (CreateDirectory(path.Substring(0, slashIndex))) |
| 129 | { |
| 130 | return true; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // Create the last directory on the path (the recursive calls will have taken care of the parent directories by now) |
| 135 | return mkdir(pathAnsi.Get(), 0755) != 0 && errno != EEXIST; |
| 136 | } |
| 137 | |
| 138 | bool AndroidFileSystem::DeleteDirectory(const String& path, bool deleteContents) |
| 139 | { |