Struct ggez::filesystem::Filesystem
[−]
[src]
pub struct Filesystem { /* fields omitted */ }
A structure that contains the filesystem state and cache.
Methods
impl Filesystem
[src]
fn new(id: &str) -> GameResult<Filesystem>
Create a new Filesystem instance, using
the given id
as a portion of the user directory path.
This function is called automatically by ggez, the end user
should never need to call it.
fn open<P: AsRef<Path>>(&mut self, path: P) -> GameResult<File>
Opens the given path and returns the resulting File
in read-only mode.
fn open_options<P: AsRef<Path>>(&mut self,
path: P,
options: OpenOptions)
-> GameResult<File>
path: P,
options: OpenOptions)
-> GameResult<File>
Opens a file in the user directory with the given std::fs::OpenOptions
.
Note that even if you open a file read-only, it can only access
files in the user directory.
fn create<P: AsRef<Path>>(&mut self, path: P) -> GameResult<File>
Creates a new file in the user directory and opens it to be written to, truncating it if it already exists.
fn create_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
Create an empty directory in the user dir with the given name. Any parents to that directory that do not exist will be created.
fn delete<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
Deletes the specified file in the user dir.
fn delete_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
Deletes the specified directory in the user dir, and all its contents!
fn exists<P: AsRef<Path>>(&mut self, path: P) -> bool
Check whether a file or directory exists.
fn is_file<P: AsRef<Path>>(&mut self, path: P) -> bool
Check whether a path points at a file.
fn is_dir<P: AsRef<Path>>(&mut self, path: P) -> bool
Check whether a path points at a directory.
fn get_root_dir(&self) -> &Path
Return the full path to the directory containing the exe
fn get_user_dir(&self) -> &Path
Return the full path to the user directory
fn get_resource_dir(&self) -> &Path
Returns the full path to the resource directory (even if it doesn't exist)
fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<ReadDir>
Returns an iterator over all files and directories in the resource directory, in no particular order.
Lists the base directory if an empty path is given.
TODO: Make it iterate over the zip file as well!
And the user dir. This probably won't happen until
returning impl Trait
hits stable, honestly.
fn print_all(&mut self) -> GameResult<()>
Prints the contents of all data directories. Useful for debugging. TODO: This should return an iterator, and be called iter()
fn read_config(&mut self) -> GameResult<Conf>
Looks for a file named "conf.toml" in the resources directory loads it if it finds it. If it can't read it for some reason, returns an error.
fn write_config(&mut self, conf: &Conf) -> GameResult<()>
Takes a conf::Conf
object and saves it to the user directory,
overwriting any file already there.