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: &'static str, author: &'static str) -> GameResult<Filesystem>
Create a new Filesystem instance, using the given id
and (on
some platforms) the author
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>
&mut self,
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>>(&self, path: P) -> bool
Check whether a file or directory exists.
fn is_file<P: AsRef<Path>>(&self, path: P) -> bool
Check whether a path points at a file.
fn is_dir<P: AsRef<Path>>(&self, path: P) -> bool
Check whether a path points at a directory.
fn get_user_data_dir(&self) -> &Path
Return the full path to the user data directory
fn get_resources_dir(&self) -> &Path
Returns the full path to the resource directory (even if it doesn't exist)
fn read_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<Vec<PathBuf>>
Returns a list of all files and directories in the resource directory, in no particular order.
Lists the base directory if an empty path is given.
fn print_all(&mut self) -> GameResult<()>
Prints the contents of all data directories. Useful for debugging.
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.