Struct playdate_file

Source
#[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

Source§

fn clone(&self) -> playdate_file

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for playdate_file

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for playdate_file

Source§

fn default() -> playdate_file

Returns the “default value” for a type. Read more
Source§

impl Hash for playdate_file

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
Source§

impl Ord for playdate_file

Source§

fn cmp(&self, other: &playdate_file) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for playdate_file

Source§

fn eq(&self, other: &playdate_file) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for playdate_file

Source§

fn partial_cmp(&self, other: &playdate_file) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for playdate_file

Source§

impl Eq for playdate_file

Source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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