FileSystemIndexer v0.1.2-beta
File System Indexer - An API to index files from your system
Loading...
Searching...
No Matches
File System Indexer

Last version of README updated: v0.1.2-beta


Support information

  • FSI Currently does not support Windows
  • Currently Linux and macOS* with other POSIX / UNIX systems

What is FSI?

File System Indexer or FSI is a C++ library that it can be used to index files quickly with an extendible and easy to use API

There is also an API for C which is just for speed-first use cases such as indexing or other usages

Requirements

To compile this program, you will need the following dependencies

  1. C11+ / C++17+ compiler
  2. jq
  3. Bash
  4. Ninja / Make (Ninja is prefered)
  5. CMake

How to Compile

Setting up

The developer can compile the code with the following snippet

./gen.sh # Generate all the required files and docs
./compile.sh settings # Developer will be prompted for config; If doxygen is not installed, it will still work

Developer Mode

With developer mode, you can get more information about unexpected crashes, have ASAN / LSAN support, debug support, ...

./compile.sh setup

Production Mode

Do not use dev mode here, just compile as prod; No information about crashes, no debug or ASAN / LSAN support

./compile.sh setup ndev

Compile the sources

./compile.sh

Run the Tests

There is a basic bash script with some utilities that you can execute the executable directly

./run.sh

Basic usage

In this example you can directly add a specific directory without its parents

fsi::IndexerInfo info; // Create object
info.path = "/path/to/fileOrDir"; // Set the path
info.id = "optional-id"; // Recommended to set an ID
indexer.addInfo(info); // Add indexer info
std::string path

Recursively index a specific dir

info.path = "/path/to/directory";
info.id = "optional-id";
indexer.addExtendedInfo(info); // Add all its subdirs starting from `info.path`

Search and manipulate indexed info

This following example will search everything in the registry and output the matching In this case, everything that includes txt

std::vector<std::string> results = indexer.searchMatching("txt");

Get all the indexed paths directly in a vector

std::vector<std::string> allPaths = indexer.getIndexPaths();

Get specific indexed info from the vector registry

fsi::IndexerInfo info = indexer.findIndex("/path/to/path");
fsi::IndexerInfo info = indexer.findIndex("id-path"); // Or search via ID
indexer.removeInfo("current-dir");

How to handle errors automatically

Replace errorVariable to a variable that has a type of IndexerError

if (__FSI_INDEXERERR_CHECK(errorVariable))
{
// Error handling here
// ...
// Print message by accessing:
// errorVariable.message
}
#define __FSI_INDEXERERR_CHECK(e)

Example usage

#include <iostream>
#include "/path/to/FSI_Indexer.hpp"
int main()
{
fsi::Indexer indexer("main-indexer");
{
info.path = "/path/to/dir";
info.id = "current-dir";
indexer.addExtendedInfo(info);
}
for (const auto &x : indexer.searchMatching("cpp"))
{
std::cout << x << "\n";
}
std::cout << "ID `current-dir` has path:" << indexer.findIndex("current-dir").path << "\n";
return 0;
}
int main()
Definition main.cpp:20