pub struct PlaydateFileSystem { /* private fields */ }Implementations§
Source§impl PlaydateFileSystem
impl PlaydateFileSystem
Sourcepub fn get_error(&self) -> Option<Error>
pub fn get_error(&self) -> Option<Error>
Returns human-readable text describing the most recent error (usually indicated by a -1 return from a filesystem function).
Sourcepub fn list_files(
&self,
path: impl AsRef<str>,
show_hidden: bool,
callback: impl FnMut(&str),
) -> Result<(), Error>
pub fn list_files( &self, path: impl AsRef<str>, show_hidden: bool, callback: impl FnMut(&str), ) -> Result<(), Error>
Calls the given callback function for every file at path. Subfolders are indicated by a trailing slash ‘/’ in filename. listfiles() does not recurse into subfolders. If showhidden is set, files beginning with a period will be included; otherwise, they are skipped. Returns 0 on success, -1 if no folder exists at path or it can’t be opened.
Sourcepub fn stat(&self, path: impl AsRef<str>) -> Result<FileStat>
pub fn stat(&self, path: impl AsRef<str>) -> Result<FileStat>
Populates the FileStat stat with information about the file at path. Returns 0 on success, or -1 in case of error.
Sourcepub fn mkdir(&self, path: impl AsRef<str>) -> Result<()>
pub fn mkdir(&self, path: impl AsRef<str>) -> Result<()>
Creates the given path in the Data/<gameid> folder. It does not create intermediate folders. Returns 0 on success, or -1 in case of error.
Sourcepub fn unlink(&self, name: impl AsRef<str>, recursive: bool) -> Result<()>
pub fn unlink(&self, name: impl AsRef<str>, recursive: bool) -> Result<()>
Deletes the file at path. Returns 0 on success, or -1 in case of error. If recursive is 1 and the target path is a folder, this deletes everything inside the folder (including folders, folders inside those, and so on) as well as the folder itself.
Sourcepub fn rename(&self, from: impl AsRef<str>, to: impl AsRef<str>) -> Result<()>
pub fn rename(&self, from: impl AsRef<str>, to: impl AsRef<str>) -> Result<()>
Renames the file at from to to. It will overwrite the file at to without confirmation. It does not create intermediate folders. Returns 0 on success, or -1 in case of error.
Sourcepub fn open(&self, name: impl AsRef<str>, mode: FileOptions) -> Result<File>
pub fn open(&self, name: impl AsRef<str>, mode: FileOptions) -> Result<File>
Opens a handle for the file at path. The kFileRead mode opens a file in the game pdx, while kFileReadData searches the game’s data folder; to search the data folder first then fall back on the game pdx, use the bitwise combination kFileRead|kFileReadData.kFileWrite and kFileAppend always write to the data folder. The function returns NULL if a file at path cannot be opened, and playdate->file->geterr() will describe the error. The filesystem has a limit of 64 simultaneous open files.