Unravel Engine C++ Reference
Loading...
Searching...
No Matches
fs Namespace Reference

Namespaces

namespace  detail
 
namespace  file_stream_detail
 

Classes

class  cache
 
class  file_istream
 stdio-backed input stream. Accepts std::ios open flags (e.g. std::ios::binary) when opening a More...
 
class  file_ostream
 stdio-backed output stream. Accepts std::ios open flags (e.g. std::ios::binary | std::ios::app) More...
 
class  pattern_filter
 A filter that combines include and exclude patterns for file/directory filtering. More...
 
struct  stream_buffer
 
class  syncer
 
class  watcher
 
class  watcher_fallback
 
class  watcher_wtr
 
class  wildcard_pattern
 A wildcard pattern matcher that supports * (match any sequence) and ? (match single character) More...
 

Typedefs

using directory_cache = cache<directory_iterator>
 
using recursive_directory_cache = cache<recursive_directory_iterator>
 
using protocols_t = std::unordered_map<std::string, std::string>
 
using byte_array_t = std::vector<std::uint8_t>
 

Enumerations

enum class  file_stream_ownership : std::uint8_t { take_ownership , retain_ownership }
 Whether a file stream wrapper should fclose its FILE* on destruction. More...
 

Functions

template<typename Iterator = recursive_directory_iterator>
auto make_filtered_cache (const fs::path &path, const std::vector< std::string > &includes, const std::vector< std::string > &excludes={}, std::chrono::steady_clock::duration scan_frequency=std::chrono::milliseconds(500)) -> cache< Iterator >
 Convenience function to create a directory cache with pattern filtering.
 
void benchmark_directory_reads (const path &directory)
 
auto hash_file_fingerprint (const path &file_path, bool normalize_text_line_endings) -> std::string
 Hash a file's contents. Text assets normalize CRLF to LF before hashing.
 
auto combine_file_fingerprints (const std::string &first_fingerprint, const std::string *additional_fingerprints, size_t additional_count) -> std::string
 Combine per-file fingerprints (raw 128-bit digests) into one hex fingerprint.
 
byte_array_t read_stream (std::istream &stream) -> byte_array_t
 Load a byte_array_t with the contents of the specified file, be that file in a package or in the main file system.
 
std::string read_stream_str (std::istream &stream)
 
stream_buffer< byte_array_tread_stream_buffer (std::istream &stream)
 
stream_buffer< std::string > read_stream_buffer_str (std::istream &stream)
 
bool add_path_protocol (const std::string &protocol, const path &directory) -> bool
 Allows us to map a protocol to a specific directory. A path protocol gives the caller the ability to prepend an identifier to their file name i.e. "engine_data://textures/tex.png" and have it return the relevant mapped path.
 
protocols_tget_path_protocols () -> protocols_t &
 Returns the registered path protocols.
 
path extract_protocol (const path &_path) -> path
 Given the specified path/filename, resolve the final full filename. This will be based on either the currently specified root path, or one of the 'path protocol' identifiers if it is included in the filename.
 
path resolve_protocol (const path &_path) -> path
 Given the specified path/filename, resolve the final full filename. This will be based on either the currently specified root path, or one of the 'path protocol' identifiers if it is included in the filename.
 
bool has_known_protocol (const path &_path) -> bool
 Checks whether the path has a known protocol.
 
path convert_to_protocol (const path &_path) -> path
 Oposite of the resolve_protocol this function tries to convert to protocol path from an absolute one.
 
path replace (const path &_path, const path &_sequence, const path &_new_sequence) -> path
 Replacing any occurences of the specified path sequence with another.
 
std::vector< path > split_until (const path &_path, const path &_predicate) -> std::vector< path >
 another.
 
path reduce_trailing_extensions (const path &_path) -> path
 another.
 
bool is_any_parent_path (const path &parent, const path &child)
 
auto make_pattern_filter (const std::string &pattern) -> pattern_filter
 Convenience function to create a pattern filter from a single wildcard string Maintains backward compatibility with existing "*" usage.
 
auto make_pattern_filter (const std::vector< std::string > &includes, const std::vector< std::string > &excludes={}) -> pattern_filter
 Convenience function to create a pattern filter with include and exclude lists.
 
static auto extract_entry_extension (const fs::path &path) -> std::string
 
static void ensure_directory_exists (const fs::path &path)
 
static auto entry_serialization_key (const fs::path &watch_root, const fs::watcher::entry &entry) -> std::string
 Paths that share a key are processed on one worker in order (create -> rename, etc.).
 
auto to_string (const watcher::entry &e) -> std::string
 
auto filetime_to_system_clock (fs::file_time_type ft) -> std::chrono::system_clock::time_point
 

Variables

constexpr uint64_t current_source_fingerprint_version = 1
 xxHash3 128-bit fingerprints (hex). Bump when the hashing or dependency-ordering scheme changes.
 
constexpr std::ios_base::openmode default_file_read_mode
 
constexpr std::ios_base::openmode default_file_write_mode
 

Typedef Documentation

◆ byte_array_t

using fs::byte_array_t = std::vector<std::uint8_t>

Definition at line 14 of file filesystem.h.

◆ directory_cache

using fs::directory_cache = cache<directory_iterator>

Definition at line 294 of file cache.hpp.

◆ protocols_t

using fs::protocols_t = std::unordered_map<std::string, std::string>

Definition at line 13 of file filesystem.h.

◆ recursive_directory_cache

using fs::recursive_directory_cache = cache<recursive_directory_iterator>

Definition at line 295 of file cache.hpp.

Enumeration Type Documentation

◆ file_stream_ownership

enum class fs::file_stream_ownership : std::uint8_t
strong

Whether a file stream wrapper should fclose its FILE* on destruction.

Enumerator
take_ownership 
retain_ownership 

Definition at line 12 of file file_stream_common.h.

Function Documentation

◆ add_path_protocol()

auto fs::add_path_protocol ( const std::string & protocol,
const path & dir )

Allows us to map a protocol to a specific directory. A path protocol gives the caller the ability to prepend an identifier to their file name i.e. "engine_data://textures/tex.png" and have it return the relevant mapped path.

Definition at line 182 of file filesystem.cpp.

◆ benchmark_directory_reads()

void fs::benchmark_directory_reads ( const path & directory)

Recursively collects regular files under directory and benchmarks three read backends (FILE*, file_istream, std::ifstream, mapped_file_reader) in two modes:

  • chunked: 64 KiB reads with a simple uint64_t byte sum per chunk
  • whole file: one read / one mapped scan over the entire file Each backend runs a cold pass (best-effort OS page cache drop beforehand) and a hot pass without cache drops. Results are logged via APPLOG_INFO.

Definition at line 418 of file file_benchmarks.cpp.

◆ combine_file_fingerprints()

auto fs::combine_file_fingerprints ( const std::string & first_fingerprint,
const std::string * additional_fingerprints,
size_t additional_count ) -> std::string

Combine per-file fingerprints (raw 128-bit digests) into one hex fingerprint.

Definition at line 211 of file file_fingerprint.cpp.

◆ convert_to_protocol()

auto fs::convert_to_protocol ( const path & _path)

Oposite of the resolve_protocol this function tries to convert to protocol path from an absolute one.

Definition at line 266 of file filesystem.cpp.

◆ ensure_directory_exists()

static void fs::ensure_directory_exists ( const fs::path & path)
static

Definition at line 29 of file syncer.cpp.

◆ entry_serialization_key()

static auto fs::entry_serialization_key ( const fs::path & watch_root,
const fs::watcher::entry & entry ) -> std::string
static

Paths that share a key are processed on one worker in order (create -> rename, etc.).

Definition at line 43 of file syncer.cpp.

◆ extract_entry_extension()

static auto fs::extract_entry_extension ( const fs::path & path) -> std::string
static

Definition at line 17 of file syncer.cpp.

◆ extract_protocol()

auto fs::extract_protocol ( const path & _path)

Given the specified path/filename, resolve the final full filename. This will be based on either the currently specified root path, or one of the 'path protocol' identifiers if it is included in the filename.

Definition at line 201 of file filesystem.cpp.

◆ filetime_to_system_clock()

auto fs::filetime_to_system_clock ( fs::file_time_type ft) -> std::chrono::system_clock::time_point
inline

Definition at line 106 of file watcher.h.

◆ get_path_protocols()

auto fs::get_path_protocols ( )

Returns the registered path protocols.

Definition at line 195 of file filesystem.cpp.

◆ has_known_protocol()

auto fs::has_known_protocol ( const path & _path)

Checks whether the path has a known protocol.

Definition at line 247 of file filesystem.cpp.

◆ hash_file_fingerprint()

auto fs::hash_file_fingerprint ( const path & file_path,
bool normalize_text_line_endings ) -> std::string

Hash a file's contents. Text assets normalize CRLF to LF before hashing.

Definition at line 201 of file file_fingerprint.cpp.

◆ is_any_parent_path()

auto fs::is_any_parent_path ( const path & parent,
const path & child )

Definition at line 345 of file filesystem.cpp.

◆ make_filtered_cache()

template<typename Iterator = recursive_directory_iterator>
auto fs::make_filtered_cache ( const fs::path & path,
const std::vector< std::string > & includes,
const std::vector< std::string > & excludes = {},
std::chrono::steady_clock::duration scan_frequency = std::chrono::milliseconds(500) ) -> cache<Iterator>

Convenience function to create a directory cache with pattern filtering.

Parameters
pathDirectory path to cache
includesInclude patterns
excludesExclude patterns
scan_frequencyHow often to scan for changes
Returns
Directory cache with pattern filtering

Definition at line 306 of file cache.hpp.

◆ make_pattern_filter() [1/2]

auto fs::make_pattern_filter ( const std::string & pattern) -> pattern_filter

Convenience function to create a pattern filter from a single wildcard string Maintains backward compatibility with existing "*" usage.

Parameters
patternSingle pattern string
Returns
Pattern filter configured with the single include pattern

Definition at line 175 of file pattern_filter.cpp.

◆ make_pattern_filter() [2/2]

auto fs::make_pattern_filter ( const std::vector< std::string > & includes,
const std::vector< std::string > & excludes = {} ) -> pattern_filter

Convenience function to create a pattern filter with include and exclude lists.

Parameters
includesInclude patterns (OR logic)
excludesExclude patterns (NOT logic)
Returns
Pattern filter configured with the specified patterns

Definition at line 180 of file pattern_filter.cpp.

◆ read_stream()

auto fs::read_stream ( std::istream & stream)

Load a byte_array_t with the contents of the specified file, be that file in a package or in the main file system.

Definition at line 154 of file filesystem.cpp.

◆ read_stream_buffer()

auto fs::read_stream_buffer ( std::istream & stream)

Definition at line 168 of file filesystem.cpp.

◆ read_stream_buffer_str()

auto fs::read_stream_buffer_str ( std::istream & stream)

Definition at line 175 of file filesystem.cpp.

◆ read_stream_str()

auto fs::read_stream_str ( std::istream & stream)

Definition at line 161 of file filesystem.cpp.

◆ reduce_trailing_extensions()

auto fs::reduce_trailing_extensions ( const path & _path)

another.

Definition at line 331 of file filesystem.cpp.

◆ replace()

auto fs::replace ( const path & _path,
const path & _sequence,
const path & _new_sequence )

Replacing any occurences of the specified path sequence with another.

Definition at line 308 of file filesystem.cpp.

◆ resolve_protocol()

auto fs::resolve_protocol ( const path & _path)

Given the specified path/filename, resolve the final full filename. This will be based on either the currently specified root path, or one of the 'path protocol' identifiers if it is included in the filename.

Definition at line 216 of file filesystem.cpp.

◆ split_until()

auto fs::split_until ( const path & _path,
const path & _predicate )

another.

Definition at line 313 of file filesystem.cpp.

◆ to_string()

auto fs::to_string ( const watcher::entry & e) -> std::string

Definition at line 99 of file watcher.cpp.

Variable Documentation

◆ current_source_fingerprint_version

uint64_t fs::current_source_fingerprint_version = 1
inlineconstexpr

xxHash3 128-bit fingerprints (hex). Bump when the hashing or dependency-ordering scheme changes.

Definition at line 11 of file file_fingerprint.h.

◆ default_file_read_mode

std::ios_base::openmode fs::default_file_read_mode
inlineconstexpr
Initial value:
=
std::ios_base::in | std::ios_base::binary

Definition at line 18 of file file_stream_common.h.

◆ default_file_write_mode

std::ios_base::openmode fs::default_file_write_mode
inlineconstexpr
Initial value:
=
std::ios_base::out | std::ios_base::binary

Definition at line 21 of file file_stream_common.h.