MCPcopy Create free account
hub / github.com/Samsung/UTopia / findFilePaths

Function findFilePaths

lib/utils/FileUtil.cpp:25–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25std::vector<std::string> findFilePaths(std::string Dir, std::string Extension) {
26 std::vector<std::string> Ret;
27 std::vector<fs::path> PathList;
28 std::set<std::string> VisitedPathSet;
29 fs::path EntryPath = fs::path(Dir);
30 if (fs::exists(EntryPath) && fs::is_directory(EntryPath)) {
31 PathList.push_back(EntryPath);
32 }
33 while (!PathList.empty()) {
34 fs::path Path = PathList.back();
35 PathList.pop_back();
36 std::string CurCanonicalPath = getCanonicalPath(Path);
37 if (VisitedPathSet.find(CurCanonicalPath) != VisitedPathSet.end()) {
38 continue;
39 }
40 VisitedPathSet.insert(CurCanonicalPath);
41 for (auto &Iter : fs::directory_iterator(Path)) {
42 auto InPath = Iter.path();
43 if (fs::is_directory(InPath)) {
44 PathList.push_back(InPath);
45 continue;
46 }
47
48 if (InPath.extension().string() == Extension) {
49 Ret.push_back(getCanonicalPath(InPath));
50 }
51 }
52 }
53 std::cout << "Found '*" << Extension << "' File Cnt: " << Ret.size() << "\n";
54 return Ret;
55}
56
57std::vector<std::string> findASTFilePaths(std::string Dir) {
58 return findFilePaths(Dir, ".ast");

Callers 3

findASTFilePathsFunction · 0.85
findJsonFilePathsFunction · 0.85
TESTFunction · 0.85

Calls 5

getCanonicalPathFunction · 0.85
emptyMethod · 0.80
endMethod · 0.80
sizeMethod · 0.80
findMethod · 0.45

Tested by 1

TESTFunction · 0.68