MCPcopy Create free account
hub / github.com/EasyRPG/Player / GetRPG2kProjectWithRenames

Method GetRPG2kProjectWithRenames

src/fileext_guesser.cpp:34–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34FileExtGuesser::RPG2KNonStandardFilenameGuesser FileExtGuesser::GetRPG2kProjectWithRenames(const FilesystemView& fs) {
35 // Try to rescue and determine file extensions.
36 // We need to figure out the names of the map tree and the DB (maps come later).
37 std::vector<RPG2KNonStandardFilenameGuesser::ExtAndSize> candidates;
38 const auto* entries = fs.ListDirectory();
39 if (entries) {
40 for (const auto &item: *entries) {
41 if (item.second.type != DirectoryTree::FileType::Regular) {
42 continue;
43 }
44
45 if (item.first.length() == RtPrefix.length() + 3 && StartsWith(item.first, RtPrefix)) {
46 std::string ext = item.first.substr(RtPrefix.length());
47 if (ext != "exe" && ext != "ini") {
48 candidates.emplace_back(item.second.name, ext, fs.GetFilesize(fs.FindFile(item.second.name)));
49 }
50 }
51
52 // Avoid needless scanning if we can't figure it out
53 if (candidates.size() > 2) {
54 break;
55 }
56 }
57
58 // Return only if we matched exactly two files.
59 if (candidates.size() == 2) {
60 RPG2KNonStandardFilenameGuesser res;
61 res.rpgRTs.first = candidates[0];
62 res.rpgRTs.second = candidates[1];
63 return res;
64 }
65 }
66
67 return RPG2KNonStandardFilenameGuesser();
68}
69
70void FileExtGuesser::GuessAndAddLmuExtension(const FilesystemView& fs, Meta const& meta, RPG2KFileExtRemap& mapping)
71{

Callers

nothing calls this directly

Calls 5

ListDirectoryMethod · 0.45
GetFilesizeMethod · 0.45
FindFileMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected