File tree Expand file tree Collapse file tree 2 files changed +14
-26
lines changed Expand file tree Collapse file tree 2 files changed +14
-26
lines changed Original file line number Diff line number Diff line change 12
12
#include < fstream>
13
13
#include < string>
14
14
15
- #include < dirent.h>
16
15
17
16
#include < pugixml.hpp>
18
17
24
23
#include " xdemangle.hpp"
25
24
#include " xparser.hpp"
26
25
26
+ #include " llvm/Support/FileSystem.h"
27
+ #include " llvm/Support/Path.h"
28
+
27
29
namespace xcpp
28
30
{
29
31
struct node_predicate
@@ -100,30 +102,18 @@ namespace xcpp
100
102
static nl::json read_tagconfs (const char * path)
101
103
{
102
104
nl::json result = nl::json::array ();
103
- DIR* directory = opendir (path);
104
- if (directory == nullptr )
105
- {
106
- return result;
107
- }
108
- dirent* item = readdir (directory);
109
- while (item != nullptr )
110
- {
111
- std::string extension = " json" ;
112
- if (item->d_type == DT_REG)
113
- {
114
- std::string fname = item->d_name ;
115
-
116
- if (fname.find (extension, (fname.length () - extension.length ())) != std::string::npos)
117
- {
118
- std::ifstream i (path + (' /' + fname));
119
- nl::json entry;
120
- i >> entry;
121
- result.emplace_back (std::move (entry));
122
- }
123
- }
124
- item = readdir (directory);
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));
125
116
}
126
- closedir (directory);
127
117
return result;
128
118
}
129
119
Original file line number Diff line number Diff line change 52
52
#include < string>
53
53
#include < vector>
54
54
55
- #include < dirent.h>
56
-
57
55
std::string DiagnosticOutput;
58
56
llvm::raw_string_ostream DiagnosticsOS (DiagnosticOutput);
59
57
auto DiagPrinter = std::make_unique<clang::TextDiagnosticPrinter>(DiagnosticsOS, new clang::DiagnosticOptions());
You can’t perform that action at this time.
0 commit comments