13#include "ciof/ciof.hpp"
15namespace fs = std::filesystem;
33 std::vector<std::string> vec;
37 if (x.path.find(find) != std::string::npos)
38 vec.emplace_back(x.path);
49 std::vector<std::string> result;
58 if (x.path.find(find) != std::string::npos)
60 std::lock_guard<std::mutex> lock(mutex);
61 result.emplace_back(x.path);
79 for (
const auto &x : iteratedPaths)
100 std::vector<std::future<std::vector<IndexerInfo>>> tasks;
102 for (
auto &chunk : chunks)
107 tasks.emplace_back(std::async(std::launch::async,
108 [&, chunk]() -> std::vector<IndexerInfo>
110 std::vector<IndexerInfo> local;
112 local.reserve(chunk.size());
114 for (
const auto &p : chunk)
119 local.emplace_back(std::move(tmp));
127 for (
auto &t : tasks)
129 auto local = t.get();
133 std::make_move_iterator(local.begin()),
134 std::make_move_iterator(local.end()));
142 std::vector<std::string> paths;
144 CVEC tmpPathsVec = cvec_init(-1,
sizeof(
char*));
146 fsi_walk(&tmpPathsVec, path.c_str());
148 for (
size_t i = 0; i < tmpPathsVec.size; ++i)
150 char* p = *(
char**)cvec_get(&tmpPathsVec, i);
154 paths.emplace_back(p, strlen(p));
160 cvec_destroy(&tmpPathsVec);
204 if (totalInfo.
path.empty())
207 error.
message =
"Path is empty";
214 if (!fs::exists(totalInfo.
path))
217 error.
message = ciof::format(
"Unknown path `%1`; No such file or directory exists", totalInfo.
path);
238 if (x.path == toFind || x.id == toFind)
251 if (searcher.empty())
254 error.
message =
"Empty value to remove from the Indexer Information list";
265 this->indexerInfo.end(),
267 return (info.id == searcher || info.path == searcher);
269 this->indexerInfo.end()
277 const fs::file_time_type &lastWriteTime = fs::last_write_time(path);
287 std::vector<std::string> additions;
290 { additions.emplace_back(x.path); }
#define __FSI_INDEXERERR_CHECK(e)
void fsi_walk(CVEC *vec, const char *path)
Walk to every directory and file and set vec to a CVEC value.
virtual std::vector< std::string > __searchMatchingStandard(const std::string &find)
Search all matching path or ID that contains path.
virtual IndexerPathType __getPathType(const std::string &path) const
Get if path from function param is a:
IndexerInfo findIndex(const std::string &toFind)
Find the index from the vector database from the indexer.
std::vector< IndexerInfo > indexerInfo
static std::vector< std::vector< std::string > > __splitPathByCores(const std::vector< std::string > &paths)
Split the paths found to be used in the future in different CPU cores.
IndexerError addInfo(const IndexerInfo &info)
Add the exact path to have the info from.
IndexerError removeInfo(const std::string &searcher)
Remove information from its ID or full path.
utils::TimeUtils_DateTime getFileDTInfo(const std::string &path)
Get when the file, dir or symlink was last modified.
std::vector< std::string > searchMatching(const std::string &path)
Either use threaded or unthreaded search matching.
Indexer(const std::string &id, const bool threadsImpl=false)
std::vector< std::string > getIndexPaths() const
Get all the indexed paths from the vector indexes.
std::string searchExactMatching(const std::string &find)
Search for an exact matching path or ID;.
virtual IndexerError __addExtendedInfoThreaded(const IndexerInfo &info)
Threaded extended information.
std::string getID() const
Get this object's ID.
IndexerError addExtendedInfo(const IndexerInfo &info)
Add the exact path and the sub-paths to have the info from;.
std::vector< IndexerInfo > getIndexerInfo() const
Return indexer information from this object.
virtual std::vector< std::string > __iteratePath(const std::string &path)
Iterate all the files and directories (symlinks too) from path.
virtual IndexerError __addExtendedInfoStandard(const IndexerInfo &info)
Standard non-threaded extended information.
virtual std::vector< std::string > __searchMatchingThreaded(const std::string &find)
Search all matching path or ID that contains path using parallelization with multiple CPU threads.
constexpr int ERROR_ADDITION_FAIL
constexpr int ERROR_INVALID_PATH
constexpr int ERROR_EMPTY_VALUE
TimeUtils_DateTime fsClockDataToDT(const fs::file_time_type &time)
Set std::filesystem clock data to an actual usable Date and Time format.