@@ -5,45 +5,30 @@ using namespace llvm;
55
66#include < utility>
77
8- static void GetFilesInFolderHelper (
9- std::string folder ,
10- bool recursive ,
11- std::string output_prefix,
12- const std::function< void ( const std::string&)>& handler) {
8+ void GetFilesInFolder (std::string folder,
9+ bool recursive ,
10+ bool dir_prefix ,
11+ const std::function< void ( const std:: string&)>& handler) {
12+ EnsureEndsInSlash (folder);
1313 std::error_code ec;
1414 if (recursive)
1515 for (sys::fs::recursive_directory_iterator I (folder, ec), E; I != E && !ec;
1616 I.increment (ec)) {
1717 std::string path = I->path (), filename = sys::path::filename (path);
1818 if (filename[0 ] != ' .' || filename == " .ccls" ) {
19- SmallString<256 > Path;
20- if (output_prefix.size ()) {
21- sys::path::append (Path, output_prefix, path);
22- handler (Path.str ());
23- } else
24- handler (path);
19+ if (!dir_prefix)
20+ path = path.substr (folder.size ());
21+ handler (path);
2522 }
2623 }
2724 else
2825 for (sys::fs::directory_iterator I (folder, ec), E; I != E && !ec;
2926 I.increment (ec)) {
3027 std::string path = I->path (), filename = sys::path::filename (path);
3128 if (filename[0 ] != ' .' || filename == " .ccls" ) {
32- SmallString<256 > Path;
33- if (output_prefix.size ()) {
34- sys::path::append (Path, output_prefix, path);
35- handler (Path.str ());
36- } else
37- handler (path);
29+ if (!dir_prefix)
30+ path = path.substr (folder.size ());
31+ handler (path);
3832 }
3933 }
4034}
41-
42- void GetFilesInFolder (std::string folder,
43- bool recursive,
44- bool add_folder_to_path,
45- const std::function<void (const std::string&)>& handler) {
46- EnsureEndsInSlash (folder);
47- GetFilesInFolderHelper (folder, recursive, add_folder_to_path ? folder : " " ,
48- handler);
49- }
0 commit comments