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,
|
"**/.git": true,
|
||||||
"**/.svn": true,
|
"**/.svn": true,
|
||||||
"**/.hg": true,
|
"**/.hg": true,
|
||||||
"**/.DS_Store": true,
|
"**/.DS_Store": true
|
||||||
"third_party/": true
|
// "third_party/": true
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -613,8 +613,6 @@ int main(int argc, char** argv) {
|
|||||||
_setmode(_fileno(stdin), O_BINARY);
|
_setmode(_fileno(stdin), O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IpcRegistry::instance()->Register<IpcMessage_Quit>();
|
IpcRegistry::instance()->Register<IpcMessage_Quit>();
|
||||||
|
|
||||||
IpcRegistry::instance()->Register<IpcMessage_IsAlive>();
|
IpcRegistry::instance()->Register<IpcMessage_IsAlive>();
|
||||||
|
33
utils.cc
33
utils.cc
@ -1,11 +1,12 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "tinydir.h"
|
#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;
|
std::vector<std::string> result;
|
||||||
|
|
||||||
tinydir_dir dir;
|
tinydir_dir dir;
|
||||||
@ -21,21 +22,17 @@ std::vector<std::string> GetFilesInFolder(std::string folder, bool add_folder_to
|
|||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string full_path;
|
// Skip all dot files.
|
||||||
if (add_folder_to_path)
|
if (file.name[0] != '.') {
|
||||||
full_path = folder + "/";
|
if (file.is_dir) {
|
||||||
full_path += file.name;
|
// Note that we must always ignore the '.' and '..' directories, otherwise
|
||||||
if (file.is_dir) {
|
// this will loop infinitely. The above check handles that for us.
|
||||||
// Ignore all dot directories.
|
for (std::string nested_file : GetFilesInFolderHelper(file.path, output_prefix + file.name + "/"))
|
||||||
// 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*/))
|
|
||||||
result.push_back(nested_file);
|
result.push_back(nested_file);
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
else {
|
result.push_back(output_prefix + file.name);
|
||||||
result.push_back(full_path);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tinydir_next(&dir) == -1) {
|
if (tinydir_next(&dir) == -1) {
|
||||||
@ -49,6 +46,14 @@ bail:
|
|||||||
return result;
|
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> ReadLines(std::string filename) {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user