Skip to content

Archmage.FS

The file system from which the loader reads atlas.json, the config files and the override files.

Inherits: RefCounted

Extend this class to read files from elsewhere, such as from memory. Archmage.FileAccessFS is the default. file_exists() and dir_exists() return true unless overridden; keep that default when checking is not possible or is expensive.

Archmage.AtlasLoader.load_atlas_async() calls read_file() and file_exists() on worker threads, several at a time, so an implementation must be safe to call that way. Protect any state that the calls share, such as one ZIPReader used for all reads, with a Mutex. dir_exists() runs on the thread that starts the load.

@abstract func read_file(path: String) -> Variant

Returns the content of the file at path as a PackedByteArray, or an Error code when the file cannot be read. Return ERR_FILE_NOT_FOUND when the file does not exist. When file_exists() returned true for an override file, the loader skips the file only on this code; any other code fails the load.

func file_exists(_path: String) -> bool

Returns whether the file at path exists. The loader calls it for each possible override file and reads only the files that exist.

func dir_exists(_path: String) -> bool

Returns whether the directory at path exists. The loader calls it for each override root and fails when it returns false.