| 124 | } |
| 125 | |
| 126 | bool Platform::File::MakeDirectory(bool follow_symlinks) const { |
| 127 | if (IsDirectory(follow_symlinks)) { |
| 128 | return true; |
| 129 | } |
| 130 | |
| 131 | #ifdef _WIN32 |
| 132 | std::string path = Utils::FromWideString(filename); |
| 133 | #else |
| 134 | std::string path = filename; |
| 135 | #endif |
| 136 | |
| 137 | auto components = FileFinder::SplitPath(path); |
| 138 | std::string cur_path; |
| 139 | if (StartsWith(path, "/")) { |
| 140 | cur_path += "/"; |
| 141 | } |
| 142 | |
| 143 | bool first = true; |
| 144 | for (const auto& comp : components) { |
| 145 | if (comp.empty() || comp == ".") { |
| 146 | continue; |
| 147 | } |
| 148 | |
| 149 | cur_path = FileFinder::MakePath(cur_path, comp); |
| 150 | |
| 151 | if (first) { |
| 152 | // Do not check stuff that looks like drives, such as C:, ux0: or sd: |
| 153 | // Some systems do not consider them directories |
| 154 | first = false; |
| 155 | if (comp.back() == ':') { |
| 156 | continue; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | #if defined(__WIIU__) |
| 161 | if (cur_path == "fs:/vol" || cur_path == "/vol") { |
| 162 | // /vol is part of the path but checking for existance fails |
| 163 | continue; |
| 164 | } |
| 165 | #endif |
| 166 | |
| 167 | File cf(cur_path); |
| 168 | if (cf.IsDirectory(follow_symlinks)) { |
| 169 | continue; |
| 170 | } else if (cf.IsFile(follow_symlinks) || cf.Exists()) { |
| 171 | return false; |
| 172 | } else { |
| 173 | #ifdef _WIN32 |
| 174 | if (!CreateDirectoryW(Utils::ToWideString(cur_path).c_str(), nullptr)) { |
| 175 | return false; |
| 176 | } |
| 177 | #else |
| 178 | # if defined(__vita__) |
| 179 | int res = sceIoMkdir(cur_path.c_str(), 0777); |
| 180 | # else |
| 181 | int res = mkdir(cur_path.c_str(), 0777); |
| 182 | # endif |
| 183 | if (res < 0) { |
no test coverage detected