Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::FileSystem Class Referencefinal

Disk-backed implementation of IAssetLoader. More...

#include <flint/resource/filesystem.h>

+ Inheritance diagram for Flint::FileSystem:
+ Collaboration diagram for Flint::FileSystem:

Public Member Functions

 FileSystem (std::filesystem::path root)
 Construct a FileSystem rooted at root.
 
FLINT_API std::vector< char > getAsset (const std::string &path) override
 Read the entire file at path and return its bytes.
 
FLINT_API uint64_t getAssetRevision (const std::string &path) const override
 Return the file's last-write-time tick count as a revision.
 
FLINT_API bool hasAsset (const std::string &path) const override
 Check whether a regular file exists at path.
 
bool isDoneLoading () const override
 Always true; FileSystem is synchronous with no background loading phase.
 
- Public Member Functions inherited from Flint::IAssetLoader

Detailed Description

Disk-backed implementation of IAssetLoader.

Loads assets from a directory tree rooted at the path given to the constructor. All asset paths are relative to that root; paths with a root name or root directory are rejected, as are paths whose canonical form resolves outside the root (including via symlinks).

Revision tracking uses file modification time, so changes are detected without re-reading contents. See getAssetRevision().

Thread safety

No internal synchronisation; concurrent calls require external locking.

Definition at line 32 of file filesystem.h.

Constructor & Destructor Documentation

◆ FileSystem()

Flint::FileSystem::FileSystem ( std::filesystem::path root)
inlineexplicit

Construct a FileSystem rooted at root.

Parameters
rootDirectory that acts as the asset root. May be absolute or relative to the process working directory.

Definition at line 40 of file filesystem.h.

Member Function Documentation

◆ getAsset()

FLINT_API std::vector< char > Flint::FileSystem::getAsset ( const std::string & path)
overridevirtual

Read the entire file at path and return its bytes.

Opened in binary mode.

Parameters
pathAsset path relative to the root directory.
Returns
Vector containing the complete file contents.
Exceptions
std::runtime_errorif the file cannot be opened, its size cannot be determined, the read fails, or path is invalid.

Implements Flint::IAssetLoader.

◆ getAssetRevision()

FLINT_API uint64_t Flint::FileSystem::getAssetRevision ( const std::string & path) const
overridevirtual

Return the file's last-write-time tick count as a revision.

Compare for equality only; the value is not ordered — restoring a backup can move it backward.

Parameters
pathAsset path relative to the root directory.
Returns
Tick count of last_write_time, or 0 if the path is invalid, absent, not a regular file, or a filesystem error occurs.

Implements Flint::IAssetLoader.

◆ hasAsset()

FLINT_API bool Flint::FileSystem::hasAsset ( const std::string & path) const
overridevirtual

Check whether a regular file exists at path.

Parameters
pathAsset path relative to the root directory.
Returns
true if the path resolves to an existing regular file.

Implements Flint::IAssetLoader.

◆ isDoneLoading()

bool Flint::FileSystem::isDoneLoading ( ) const
inlineoverridevirtual

Always true; FileSystem is synchronous with no background loading phase.

Returns
true.

Implements Flint::IAssetLoader.

Definition at line 81 of file filesystem.h.


The documentation for this class was generated from the following file: