| 162 | } |
| 163 | |
| 164 | bool ensureDirectoryPath(const std::u16string& base, const std::string& relPath) |
| 165 | { |
| 166 | std::u16string current = base; |
| 167 | size_t start = 0; |
| 168 | while (true) { |
| 169 | size_t pos = relPath.find('/', start); |
| 170 | if (pos == std::string::npos) { |
| 171 | break; |
| 172 | } |
| 173 | std::string part = relPath.substr(start, pos - start); |
| 174 | if (!part.empty()) { |
| 175 | current += StringUtils::UTF8toUTF16(part.c_str()); |
| 176 | if (!io::directoryExists(Archive::sdmc(), current)) { |
| 177 | io::createDirectory(Archive::sdmc(), current); |
| 178 | } |
| 179 | current += StringUtils::UTF8toUTF16("/"); |
| 180 | } |
| 181 | start = pos + 1; |
| 182 | } |
| 183 | return true; |
| 184 | } |
| 185 | |
| 186 | // Reads a bounded head window off the front of the streamed body so |
| 187 | // TransferProto::parseMultipart can locate the parts without scanning the |