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

Method OpenViewToEasyRpgFile

src/filefinder.cpp:361–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361bool FileFinder::OpenViewToEasyRpgFile(FilesystemView& fs) {
362 auto files = fs.ListDirectory();
363 if (!files) {
364 return false;
365 }
366
367 int items = 0;
368 std::string filename;
369
370 for (auto& file : *files) {
371 if (EndsWith(file.second.name, ".easyrpg")) {
372 ++items;
373 if (items == 2) {
374 // Contains more than one game
375 return false;
376 }
377 filename = file.second.name;
378 }
379 }
380
381 if (filename.empty()) {
382 return false;
383 }
384
385 // One candidate to check
386 auto ep_fs = fs.Create(filename);
387 if (FileFinder::IsValidProject(ep_fs)) {
388 fs = ep_fs;
389 return true;
390 } else {
391 return false;
392 }
393}
394
395bool FileFinder::HasSavegame() {
396 return GetSavegames() > 0;

Callers

nothing calls this directly

Calls 3

ListDirectoryMethod · 0.45
emptyMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected