#[repr(C)]pub struct playdate_file {Show 13 fields
pub geterr: Option<unsafe extern "C" fn() -> *const c_char>,
pub listfiles: Option<unsafe extern "C" fn(path: *const c_char, callback: Option<unsafe extern "C" fn(path: *const c_char, userdata: *mut c_void)>, userdata: *mut c_void, showhidden: c_int) -> c_int>,
pub stat: Option<unsafe extern "C" fn(path: *const c_char, stat: *mut FileStat) -> c_int>,
pub mkdir: Option<unsafe extern "C" fn(path: *const c_char) -> c_int>,
pub unlink: Option<unsafe extern "C" fn(name: *const c_char, recursive: c_int) -> c_int>,
pub rename: Option<unsafe extern "C" fn(from: *const c_char, to: *const c_char) -> c_int>,
pub open: Option<unsafe extern "C" fn(name: *const c_char, mode: FileOptions) -> *mut SDFile>,
pub close: Option<unsafe extern "C" fn(file: *mut SDFile) -> c_int>,
pub read: Option<unsafe extern "C" fn(file: *mut SDFile, buf: *mut c_void, len: c_uint) -> c_int>,
pub write: Option<unsafe extern "C" fn(file: *mut SDFile, buf: *const c_void, len: c_uint) -> c_int>,
pub flush: Option<unsafe extern "C" fn(file: *mut SDFile) -> c_int>,
pub tell: Option<unsafe extern "C" fn(file: *mut SDFile) -> c_int>,
pub seek: Option<unsafe extern "C" fn(file: *mut SDFile, pos: c_int, whence: c_int) -> c_int>,
}Fields§
§geterr: Option<unsafe extern "C" fn() -> *const c_char>const char* playdate->file->geterr(void);
Returns human-readable text describing the most recent error (usually indicated by a -1 return from a filesystem function).
listfiles: Option<unsafe extern "C" fn(path: *const c_char, callback: Option<unsafe extern "C" fn(path: *const c_char, userdata: *mut c_void)>, userdata: *mut c_void, showhidden: c_int) -> c_int>int playdate->file->listfiles(const char* path, void (*callback)(const char* filename, void* userdata), void* userdata, int showhidden);
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.
Equivalent to playdate.file.listFiles() in the Lua API.
stat: Option<unsafe extern "C" fn(path: *const c_char, stat: *mut FileStat) -> c_int>int playdate->file->stat(const char* path, FileStat* stat);
Populates the FileStat stat with information about the file at path. Returns 0 on success, or -1 in case of error.
FileStat
typedef struct
{
int isdir;
unsigned int size;
int m_year;
int m_month;
int m_day;
int m_hour;
int m_minute;
int m_second;
} FileStat;mkdir: Option<unsafe extern "C" fn(path: *const c_char) -> c_int>int playdate->file->mkdir(const char* path);
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.
Equivalent to playdate.file.mkdir() in the Lua API.
unlink: Option<unsafe extern "C" fn(name: *const c_char, recursive: c_int) -> c_int>int playdate->file->unlink(const char* path, int recursive);
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.
rename: Option<unsafe extern "C" fn(from: *const c_char, to: *const c_char) -> c_int>int playdate->file->rename(const char* from, const char* to);
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.
Equivalent to playdate.file.rename() in the Lua API.
open: Option<unsafe extern "C" fn(name: *const c_char, mode: FileOptions) -> *mut SDFile>SDFile* playdate->file->open(const char* path, FileOptions mode);
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. The returned file handle should be closed, not freed, when it is no longer in use.
FileOptions
typedef enum
{
kFileRead,
kFileReadData,
kFileWrite,
kFileAppend
} FileOptions;Equivalent to playdate.file.open() in the Lua API.
close: Option<unsafe extern "C" fn(file: *mut SDFile) -> c_int>int playdate->file->close(SDFile* file);
Closes the given file handle. Returns 0 on success, or -1 in case of error.
Equivalent to playdate.file.close() in the Lua API.
read: Option<unsafe extern "C" fn(file: *mut SDFile, buf: *mut c_void, len: c_uint) -> c_int>int playdate->file->read(SDFile* file, void* buf, unsigned int len);
Reads up to len bytes from the file into the buffer buf. Returns the number of bytes read (0 indicating end of file), or -1 in case of error.
Equivalent to playdate.file.file:read() in the Lua API.
write: Option<unsafe extern "C" fn(file: *mut SDFile, buf: *const c_void, len: c_uint) -> c_int>int playdate->file->write(SDFile* file, const void* buf, unsigned int len);
Writes the buffer of bytes buf to the file. Returns the number of bytes written, or -1 in case of error.
Equivalent to playdate.file.file:write() in the Lua API.
flush: Option<unsafe extern "C" fn(file: *mut SDFile) -> c_int>int playdate->file->flush(SDFile* file);
Flushes the output buffer of file immediately. Returns the number of bytes written, or -1 in case of error.
Equivalent to playdate.file.flush() in the Lua API.
tell: Option<unsafe extern "C" fn(file: *mut SDFile) -> c_int>int playdate->file->tell(SDFile* file);
Returns the current read/write offset in the given file handle, or -1 on error.
Equivalent to playdate.file.file:tell() in the Lua API.
seek: Option<unsafe extern "C" fn(file: *mut SDFile, pos: c_int, whence: c_int) -> c_int>int playdate->file->seek(SDFile* file, int pos, int whence);
Sets the read/write offset in the given file handle to pos, relative to the whence macro. SEEK_SET is relative to the beginning of the file, SEEK_CUR is relative to the current position of the file pointer, and SEEK_END is relative to the end of the file. Returns 0 on success, -1 on error.
Equivalent to playdate.file.file:seek() in the Lua API.
Trait Implementations§
Source§impl Clone for playdate_file
impl Clone for playdate_file
Source§fn clone(&self) -> playdate_file
fn clone(&self) -> playdate_file
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for playdate_file
impl Debug for playdate_file
Source§impl Default for playdate_file
impl Default for playdate_file
Source§fn default() -> playdate_file
fn default() -> playdate_file
Source§impl Hash for playdate_file
impl Hash for playdate_file
Source§impl Ord for playdate_file
impl Ord for playdate_file
Source§impl PartialEq for playdate_file
impl PartialEq for playdate_file
Source§impl PartialOrd for playdate_file
impl PartialOrd for playdate_file
Source§fn partial_cmp(&self, other: &playdate_file) -> Option<Ordering>
fn partial_cmp(&self, other: &playdate_file) -> Option<Ordering>
impl Copy for playdate_file
impl Eq for playdate_file
impl StructuralPartialEq for playdate_file
Auto Trait Implementations§
impl Freeze for playdate_file
impl RefUnwindSafe for playdate_file
impl Send for playdate_file
impl Sync for playdate_file
impl Unpin for playdate_file
impl UnwindSafe for playdate_file
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<T> ToOwned for Twhere
T: Clone,
impl<T> ToOwned for Twhere
T: Clone,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 52 bytes