Struct ggez::filesystem::Filesystem [−][src]
pub struct Filesystem { /* fields omitted */ }
A structure that contains the filesystem state and cache.
Methods
impl Filesystem
[src]
impl Filesystem
pub fn new(id: &'static str, author: &'static str) -> GameResult<Filesystem>
[src]
pub 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.
pub fn open<P: AsRef<Path>>(&mut self, path: P) -> GameResult<File>
[src]
pub fn open<P: AsRef<Path>>(&mut self, path: P) -> GameResult<File>
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]
pub fn open_options<P: AsRef<Path>>(
&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]
pub 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.
pub fn create_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
[src]
pub 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.
pub fn delete<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
[src]
pub fn delete<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
Deletes the specified file in the user dir.
pub fn delete_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
[src]
pub fn delete_dir<P: AsRef<Path>>(&mut self, path: P) -> GameResult<()>
Deletes the specified directory in the user dir, and all its contents!
pub fn exists<P: AsRef<Path>>(&self, path: P) -> bool
[src]
pub fn exists<P: AsRef<Path>>(&self, path: P) -> bool
Check whether a file or directory exists.
pub fn is_file<P: AsRef<Path>>(&self, path: P) -> bool
[src]
pub fn is_file<P: AsRef<Path>>(&self, path: P) -> bool
Check whether a path points at a file.
pub fn is_dir<P: AsRef<Path>>(&self, path: P) -> bool
[src]
pub fn is_dir<P: AsRef<Path>>(&self, path: P) -> bool
Check whether a path points at a directory.
pub fn get_user_data_dir(&self) -> &Path
[src]
pub fn get_user_data_dir(&self) -> &Path
Return the full path to the user data directory
pub fn get_user_config_dir(&self) -> &Path
[src]
pub fn get_user_config_dir(&self) -> &Path
Return the full path to the user config directory
pub fn get_resources_dir(&self) -> &Path
[src]
pub fn get_resources_dir(&self) -> &Path
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]
pub fn read_dir<P: AsRef<Path>>(
&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]
pub fn print_all(&mut self)
Prints the contents of all data directories. Useful for debugging.
pub fn log_all(&mut self)
[src]
pub fn log_all(&mut self)
Outputs the contents of all data directories,
using the "info" log level of the log
crate.
Useful for debugging.
See the logging
example for how to collect
log information.
pub fn mount(&mut self, path: &Path, readonly: bool)
[src]
pub fn mount(&mut self, path: &Path, readonly: bool)
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]
pub fn read_config(&mut self) -> GameResult<Conf>
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]
pub 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.
Trait Implementations
impl Debug for Filesystem
[src]
impl Debug for Filesystem
Auto Trait Implementations
impl !Send for Filesystem
impl !Send for Filesystem
impl !Sync for Filesystem
impl !Sync for Filesystem