A cross-platform interface to the filesystem.
This module provides access to files in specific places:
resources/subdirectory in the same directory as the program executable, if any,
resources.zipfile in the same directory as the program executable, if any,
- The root folder of the game's "save" directory which is in a
~/.local/share/<gameid>/on Linux. The
gameidis the the string passed to
ContextBuilder::new(). Some platforms such as Windows also incorporate the
authorstring into the path.
These locations will be searched for files in the order listed, and the first file
found used. That allows game assets to be easily distributed as an archive
file, but locally overridden for testing or modding simply by putting
altered copies of them in the game's
resources/ directory. It
is loosely based off of the
See the source of the
files example for more details.
Note that the file lookups WILL follow symlinks! This module's directory isolation is intended for convenience, not security, so don't assume it will be secure.
A structure that contains the filesystem state and cache.
Options for opening files
Represents a file, either in the filesystem, or in the resources zip file, or whatever.
Creates a new file in the user directory and opens it to be written to, truncating it if it already exists.
Create an empty directory in the user dir with the given name. Any parents to that directory that do not exist will be created.
Deletes the specified file in the user dir.
Deletes the specified directory in the user dir, and all its contents!
Check whether a file or directory exists.
Check whether a path points at a directory.
Check whether a path points at a file.
Outputs the contents of all data directories,
using the "info" log level of the
Adds the given (absolute) path to the list of directories it will search to look for resources.
Opens the given path and returns the resulting
Opens a file in the user directory with the given
Prints the contents of all data directories. Useful for debugging.
Looks for a file named
Returns a list of all files and directories in the resource directory, in no particular order.
Returns the full path to the resource directory (even if it doesn't exist)
Return the full path to the user config directory
Return the full path to the user data directory