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

Method FindFiles

common/FileSystem.cpp:1572–1610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1570}
1571
1572bool FileSystem::FindFiles(const char* path, const char* pattern, u32 flags, FindResultsArray* results, ProgressCallback* cancel)
1573{
1574 // has a path
1575 if (path[0] == '\0')
1576 return false;
1577
1578 // clear result array
1579 if (!(flags & FILESYSTEM_FIND_KEEP_ARRAY))
1580 results->clear();
1581
1582 // add self if recursive, we don't want to visit it twice
1583 std::vector<std::string> visited;
1584 if (flags & FILESYSTEM_FIND_RECURSIVE)
1585 {
1586 std::string real_path = Path::RealPath(path);
1587 if (!real_path.empty())
1588 visited.push_back(std::move(real_path));
1589 }
1590
1591 // enter the recursive function
1592 if (RecursiveFindFiles(path, nullptr, nullptr, pattern, flags, results, visited, cancel) == 0)
1593 return false;
1594
1595 if (flags & FILESYSTEM_FIND_SORT_BY_NAME)
1596 {
1597 std::sort(results->begin(), results->end(), [](const FILESYSTEM_FIND_DATA& lhs, const FILESYSTEM_FIND_DATA& rhs) {
1598 // directories first
1599 if ((lhs.Attributes & FILESYSTEM_FILE_ATTRIBUTE_DIRECTORY) !=
1600 (rhs.Attributes & FILESYSTEM_FILE_ATTRIBUTE_DIRECTORY))
1601 {
1602 return ((lhs.Attributes & FILESYSTEM_FILE_ATTRIBUTE_DIRECTORY) != 0);
1603 }
1604
1605 return (StringUtil::Strcasecmp(lhs.FileName.c_str(), rhs.FileName.c_str()) < 0);
1606 });
1607 }
1608
1609 return true;
1610}
1611
1612static void TranslateStat64(struct stat* st, const struct _stat64& st64)
1613{

Callers

nothing calls this directly

Calls 8

RecursiveFindFilesFunction · 0.85
StrcasecmpFunction · 0.85
clearMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected