| 145 | } |
| 146 | |
| 147 | void Title::loadBackupList(const std::u16string& basePath, const std::vector<std::u16string>& additionalFolders, bool descending, |
| 148 | std::vector<std::u16string>& names, std::vector<std::u16string>& fullPaths) |
| 149 | { |
| 150 | Directory baselist(Archive::sdmc(), basePath); |
| 151 | if (baselist.good()) { |
| 152 | for (size_t i = 0, sz = baselist.size(); i < sz; i++) { |
| 153 | if (baselist.folder(i)) { |
| 154 | names.push_back(baselist.entry(i)); |
| 155 | fullPaths.push_back(basePath + StringUtils::UTF8toUTF16("/") + baselist.entry(i)); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | if (descending) { |
| 160 | std::sort(names.rbegin(), names.rend()); |
| 161 | std::sort(fullPaths.rbegin(), fullPaths.rend()); |
| 162 | } |
| 163 | else { |
| 164 | std::sort(names.begin(), names.end()); |
| 165 | std::sort(fullPaths.begin(), fullPaths.end()); |
| 166 | } |
| 167 | names.insert(names.begin(), StringUtils::UTF8toUTF16("New...")); |
| 168 | fullPaths.insert(fullPaths.begin(), StringUtils::UTF8toUTF16("New...")); |
| 169 | } |
| 170 | else { |
| 171 | Logging::error("Couldn't retrieve the directory list for the title {}", shortDescription()); |
| 172 | } |
| 173 | |
| 174 | // backups from configured additional folders, appended unsorted after "New..." |
| 175 | try { |
| 176 | for (const auto& folder : additionalFolders) { |
| 177 | if (!io::directoryExists(Archive::sdmc(), folder)) { |
| 178 | Logging::error("Additional folder does not exist: {}", StringUtils::UTF16toUTF8(folder)); |
| 179 | continue; |
| 180 | } |
| 181 | Directory list(Archive::sdmc(), folder); |
| 182 | if (!list.good()) { |
| 183 | Logging::error("Additional folder is not good: {}", StringUtils::UTF16toUTF8(folder)); |
| 184 | continue; |
| 185 | } |
| 186 | for (size_t i = 0, sz = list.size(); i < sz; i++) { |
| 187 | if (list.folder(i)) { |
| 188 | names.push_back(list.entry(i)); |
| 189 | fullPaths.push_back(folder + StringUtils::UTF8toUTF16("/") + list.entry(i)); |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | catch (const std::exception& e) { |
| 195 | Logging::error("Exception when processing additional folders: {}", e.what()); |
| 196 | } |
| 197 | catch (...) { |
| 198 | Logging::error("Unknown exception when processing additional folders for title {:X}", mId); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | void Title::refreshDirectories(void) |
| 203 | { |