mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 17:11:59 +00:00
fix file finding
This commit is contained in:
parent
36f69e61a9
commit
852a4218ba
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -12,7 +12,7 @@
|
||||
"**/.git": true,
|
||||
"**/.svn": true,
|
||||
"**/.hg": true,
|
||||
"**/.DS_Store": true,
|
||||
"third_party/": true
|
||||
"**/.DS_Store": true
|
||||
// "third_party/": true
|
||||
}
|
||||
}
|
@ -613,8 +613,6 @@ int main(int argc, char** argv) {
|
||||
_setmode(_fileno(stdin), O_BINARY);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
IpcRegistry::instance()->Register<IpcMessage_Quit>();
|
||||
|
||||
IpcRegistry::instance()->Register<IpcMessage_IsAlive>();
|
||||
|
33
utils.cc
33
utils.cc
@ -1,11 +1,12 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "tinydir.h"
|
||||
|
||||
std::vector<std::string> GetFilesInFolder(std::string folder, bool add_folder_to_path) {
|
||||
static std::vector<std::string> GetFilesInFolderHelper(std::string folder, std::string output_prefix) {
|
||||
std::vector<std::string> result;
|
||||
|
||||
tinydir_dir dir;
|
||||
@ -21,21 +22,17 @@ std::vector<std::string> GetFilesInFolder(std::string folder, bool add_folder_to
|
||||
goto bail;
|
||||
}
|
||||
|
||||
std::string full_path;
|
||||
if (add_folder_to_path)
|
||||
full_path = folder + "/";
|
||||
full_path += file.name;
|
||||
if (file.is_dir) {
|
||||
// Ignore all dot directories.
|
||||
// Note that we must always ignore the '.' and '..' directories, otherwise
|
||||
// this will loop infinitely.
|
||||
if (file.name[0] != '.') {
|
||||
for (std::string nested_file : GetFilesInFolder(full_path, true /*add_folder_to_path*/))
|
||||
// Skip all dot files.
|
||||
if (file.name[0] != '.') {
|
||||
if (file.is_dir) {
|
||||
// Note that we must always ignore the '.' and '..' directories, otherwise
|
||||
// this will loop infinitely. The above check handles that for us.
|
||||
for (std::string nested_file : GetFilesInFolderHelper(file.path, output_prefix + file.name + "/"))
|
||||
result.push_back(nested_file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.push_back(full_path);
|
||||
else {
|
||||
result.push_back(output_prefix + file.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (tinydir_next(&dir) == -1) {
|
||||
@ -49,6 +46,14 @@ bail:
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetFilesInFolder(std::string folder, bool add_folder_to_path) {
|
||||
assert(folder.size() > 0);
|
||||
if (folder[folder.size() - 1] != '/')
|
||||
folder += '/';
|
||||
|
||||
return GetFilesInFolderHelper(folder, add_folder_to_path ? folder : "");
|
||||
}
|
||||
|
||||
std::vector<std::string> ReadLines(std::string filename) {
|
||||
std::vector<std::string> result;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user