| 23 | } |
| 24 | |
| 25 | std::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 | |
| 57 | std::vector<std::string> findASTFilePaths(std::string Dir) { |
| 58 | return findFilePaths(Dir, ".ast"); |