Class FileIndex

Class Documentation

class FileIndex

Incremental file index by extension beneath explicitly supplied directories.

There is no refresh/removal or internal synchronization. Construct a new manager to rescan a previously indexed root.

Public Functions

FileIndex(const std::filesystem::path &root_path)

Scan root_path using search_directory(); missing/non-directory roots add nothing.

void search_directory(const std::filesystem::path &directory)

Append regular files beneath an unvisited directory and mark encountered directories as visited.

Keys use path equality without canonicalization; alternate paths can index the same physical file more than once. Extensions are lowercased with their leading dot; extensionless files use “file_no_ext”. Enumeration is unsorted. Filesystem/allocation errors propagate and can leave a partial index with the root marked visited; recreate the index to retry.

const std::vector<::CE::Files::Path> &get_files_of_type(::CE::Files::Extension extension)

Borrow the manager-owned vector for a lowercased extension key.

A missing key inserts an empty bucket; use “.png”, not “png”, or “file_no_ext”. Reborrow after assigning/moving the manager or replacing its index; destruction invalidates the reference. Later directory indexing can change the vector’s contents and invalidate its element references/iterators. Serialize this lookup with all other access; insertion can allocate/throw.

inline const std::unordered_map<::CE::Files::Extension, std::vector<::CE::Files::Path>> &files_by_type() const noexcept

Declaration: [[nodiscard]]

See also

File indexing

Returns:

Borrowed extension buckets without inserting a missing key. Retain this index and serialize access with scans/assignment/moves; further indexing may change bucket contents and invalidate element references/iterators.