Skip to content

Commit b59b086

Browse files
committed
Use <filesystem> and c++17 to iterate the folders
1 parent e2613d7 commit b59b086

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/xinspect.hpp

+8-14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef XEUS_CPP_INSPECT_HPP
1010
#define XEUS_CPP_INSPECT_HPP
1111

12+
#include <filesystem>
1213
#include <fstream>
1314
#include <string>
1415

@@ -23,9 +24,6 @@
2324
#include "xdemangle.hpp"
2425
#include "xparser.hpp"
2526

26-
#include "llvm/Support/FileSystem.h"
27-
#include "llvm/Support/Path.h"
28-
2927
namespace xcpp
3028
{
3129
struct node_predicate
@@ -102,17 +100,13 @@ namespace xcpp
102100
static nl::json read_tagconfs(const char* path)
103101
{
104102
nl::json result = nl::json::array();
105-
std::error_code EC;
106-
for (llvm::sys::fs::directory_iterator File(path, EC), FileEnd;
107-
File != FileEnd && !EC; File.increment(EC)) {
108-
llvm::StringRef FilePath = File->path();
109-
llvm::StringRef FileName = llvm::sys::path::filename(FilePath);
110-
if (!FileName.endswith("json"))
111-
continue;
112-
std::ifstream i(FilePath.str());
113-
nl::json entry;
114-
i >> entry;
115-
result.emplace_back(std::move(entry));
103+
for (const auto &entry: std::filesystem::directory_iterator(path)) {
104+
if (entry.path().extension() != ".json")
105+
continue;
106+
std::ifstream i(entry.path());
107+
nl::json json_entry;
108+
i >> json_entry;
109+
result.emplace_back(std::move(json_entry));
116110
}
117111
return result;
118112
}

0 commit comments

Comments
 (0)