Struct ggez::filesystem::Filesystem
[−]
[src]
pub struct Filesystem { /* fields omitted */ }
A structure that contains the filesystem state and cache.
Methods
impl Filesystem
[src]
pub fn new(id: &'static str, author: &'static str) -> GameResult<Filesystem>
[src]
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.
pub fn open<P: AsRef<Path>>(&mut self, path: P) -> GameResult<File>
[src]
Opens the given path and returns the resulting File
in read-only mode.
pub fn open_options<P: AsRef<Path>>(
&mut self,
path: P,
options: &OpenOptions
) -> GameResult<File>
[src]
&mut self,
path: P,
options: &OpenOptions
) -> GameResult<File>
Opens a file in the user directory with the given filesystem::OpenOptions
.
Note that even if you open a file read-only, it can only access
files in the user directory.
pub fn create<P: AsRef<Path>>(&mut self, path: P) -> GameResult<File>
[src]
Creates a new file in the user directory and opens it to be written to, truncating it if it already exists.
pub fn create_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
[src]
Create an empty directory in the user dir with the given name. Any parents to that directory that do not exist will be created.
pub fn delete<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
[src]
Deletes the specified file in the user dir.
pub fn delete_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
[src]
Deletes the specified directory in the user dir, and all its contents!
pub fn exists<P: AsRef<Path>>(&self, path: P) -> bool
[src]
Check whether a file or directory exists.
pub fn is_file<P: AsRef<Path>>(&self, path: P) -> bool
[src]
Check whether a path points at a file.
pub fn is_dir<P: AsRef<Path>>(&self, path: P) -> bool
[src]
Check whether a path points at a directory.
pub fn get_user_data_dir(&self) -> &Path
[src]
Return the full path to the user data directory
pub fn get_user_config_dir(&self) -> &Path
[src]
Return the full path to the user config directory
pub fn get_resources_dir(&self) -> &Path
[src]
Returns the full path to the resource directory (even if it doesn't exist)
pub fn read_dir<P: AsRef<Path>>(
&mut self,
path: P
) -> GameResult<Box<Iterator<Item = PathBuf>>>
[src]
&mut self,
path: P
) -> GameResult<Box<Iterator<Item = 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.
pub fn print_all(&mut self)
[src]
Prints the contents of all data directories. Useful for debugging.
pub fn mount(&mut self, path: &Path, readonly: bool)
[src]
Adds the given (absolute) path to the list of directories it will search to look for resources.
You probably shouldn't use this in the general case, since it is
harder than it looks to make it bulletproof across platforms.
But it can be very nice for debugging and dev purposes, such as
by pushing $CARGO_MANIFEST_DIR/resources
to it
pub fn read_config(&mut self) -> GameResult<Conf>
[src]
Looks for a file named "/conf.toml" in any resource directory and loads it if it finds it. If it can't read it for some reason, returns an error.
pub fn write_config(&mut self, conf: &Conf) -> GameResult<()>
[src]
Takes a conf::Conf
object and saves it to the user directory,
overwriting any file already there.