[−][src]Module ggez::filesystem
A cross-platform interface to the filesystem.
This module provides access to files in specific places:
- The
resources/
subdirectory in the same directory as the program executable, - The
resources.zip
file in the same directory as the program executable, - The root folder of the game's "save" directory which is in a
platform-dependent location,
such as
~/.local/share/<gameid>/
on Linux. Thegameid
is the the string passed toContextBuilder::new()
. Some platforms such as Windows also incorporate theauthor
string 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 PhysicsFS
library.
See the source of the files
example for more details.
Note that the file lookups WILL follow symlinks! This is for convenience more than security, so don't treat it as being secure.
Structs
Filesystem | A structure that contains the filesystem state and cache. |
OpenOptions | Options for opening files |
Enums
File | Represents a file, either in the filesystem, or in the resources zip file, or whatever. |
Functions
create | Creates a new file in the user directory and opens it to be written to, truncating it if it already exists. |
create_dir | Create an empty directory in the user dir with the given name. Any parents to that directory that do not exist will be created. |
delete | Deletes the specified file in the user dir. |
delete_dir | Deletes the specified directory in the user dir, and all its contents! |
exists | Check whether a file or directory exists. |
is_dir | Check whether a path points at a directory. |
is_file | Check whether a path points at a file. |
log_all | Outputs the contents of all data directories,
using the "info" log level of the |
mount | Adds the given (absolute) path to the list of directories it will search to look for resources. |
open | Opens the given path and returns the resulting |
open_options | Opens a file in the user directory with the given |
print_all | Prints the contents of all data directories. Useful for debugging. |
read_config | Looks for a file named |
read_dir | Returns a list of all files and directories in the resource directory, in no particular order. |
resources_dir | Returns the full path to the resource directory (even if it doesn't exist) |
user_config_dir | Return the full path to the user config directory |
user_data_dir | Return the full path to the user data directory |
write_config | Takes a |