| 43 | static const u32 RES_FS_PAST_DATA = 0xD900458B; |
| 44 | |
| 45 | static std::u16string rawBackupFile(const std::u16string& folder) |
| 46 | { |
| 47 | std::u16string canonical = folder + StringUtils::UTF8toUTF16("00000001.sav"); |
| 48 | if (io::fileExists(Archive::sdmc(), canonical)) { |
| 49 | return canonical; |
| 50 | } |
| 51 | |
| 52 | Directory dir(Archive::sdmc(), folder); |
| 53 | if (!dir.good()) { |
| 54 | return canonical; |
| 55 | } |
| 56 | std::u16string only; |
| 57 | for (size_t i = 0, sz = dir.size(); i < sz; i++) { |
| 58 | if (dir.folder(i)) { |
| 59 | continue; |
| 60 | } |
| 61 | if (!only.empty()) { |
| 62 | // More than one candidate: stay with the canonical name so the |
| 63 | // failure names the file Checkpoint expects. |
| 64 | return canonical; |
| 65 | } |
| 66 | only = folder + dir.entry(i); |
| 67 | } |
| 68 | return only.empty() ? canonical : only; |
| 69 | } |
| 70 | |
| 71 | bool io::fileExists(const std::string& path) |
| 72 | { |