MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / AddFolder

Method AddFolder

pcsx2/SIO/Memcard/MemoryCardFolder.cpp:448–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent /* = nullptr */, const bool enableFiltering /* = false */, const std::string_view filter /* = "" */)
449{
450 if (FileSystem::DirectoryExists(dirPath.c_str()))
451 {
452 std::string localFilter;
453 if (enableFiltering)
454 {
455 bool hasFilter = !filter.empty();
456 if (hasFilter)
457 {
458 localFilter = fmt::format("DATA-SYSTEM/BWNETCNF/{}", filter);
459 }
460 else
461 {
462 localFilter = "DATA-SYSTEM/BWNETCNF";
463 }
464 }
465
466 int entryNumber = 2; // include . and ..
467 for (const auto& file : GetOrderedFiles(dirPath))
468 {
469 if (file.m_isFile)
470 {
471 // don't load files in the root dir if we're filtering; no official software stores files there
472 if (parent == nullptr)
473 {
474 continue;
475 }
476 if (AddFile(dirEntry, dirPath, file, parent))
477 {
478 ++entryNumber;
479 }
480 }
481 else
482 {
483 // if possible filter added directories by game serial
484 // this has the effective result of only files relevant to the current game being loaded into the memory card
485 // which means every game essentially sees the memory card as if no other files exist
486 if (enableFiltering && !FilterMatches(file.m_fileName, localFilter))
487 {
488 continue;
489 }
490
491 // is a subdirectory
492 const std::string filePath(Path::Combine(dirPath, file.m_fileName));
493
494 // make sure we have enough space on the memcard for the directory
495 const u32 newNeededClusters = CalculateRequiredClustersOfDirectory(filePath) + ((dirEntry->entry.data.length % 2) == 0 ? 1 : 0);
496 if (newNeededClusters > GetAmountFreeDataClusters())
497 {
498 Console.Warning(GetCardFullMessage(file.m_fileName));
499 continue;
500 }
501
502 // add entry for subdir in parent dir
503 MemoryCardFileEntry* newDirEntry = AppendFileEntryToDir(dirEntry);
504 dirEntry->entry.data.length++;
505

Callers

nothing calls this directly

Calls 8

FilterMatchesFunction · 0.85
CombineFunction · 0.85
StrlcpyFunction · 0.85
formatFunction · 0.50
c_strMethod · 0.45
emptyMethod · 0.45
WarningMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected