|
enum | File_Error {
FILE_OK = 0
, FILE_ENOMEM = -1
, FILE_EINVAL = -2
, FILE_EDEVFAIL = -3
,
FILE_EMOUNTED = -4
, FILE_EACCES = -5
, FILE_EBADFSID = -6
, FILE_ENOVOLUME = -7
,
FILE_ENOPATH = -8
, FILE_EEXIST = -9
, FILE_ENAMETOOLONG = -10
, FILE_EOUTOFBOUND = -11
,
FILE_EUNFORMAT = -12
, FILE_ENOSPC = -13
, FILE_ENOENT = -14
, FILE_EISDIRECTORY = -15
,
FILE_ESHARE = -16
, FILE_EMFILE = -17
, FILE_EBADF = -18
, FILE_EEOF = -19
,
FILE_ENOTEMPTY = -20
, FILE_ECLUSTERSIZEMISMATCH = -40
, FILE_ESYSTEM = -99
} |
|
enum | File_Whence { FILE_SEEK_SET = 0
, FILE_SEEK_CUR = 1
, FILE_SEEK_END = 2
} |
|
enum | File_Open { FILE_OPEN_READ = 1 << 0
, FILE_OPEN_WRITE = 1 << 1
, FILE_OPEN_CREATE = 1 << 2
, FILE_OPEN_APPEND = 1 << 4
} |
|
|
enum File_Error(* | File_Close )(int fd) |
|
enum File_Error(* | File_FindClose )(int findHandle) |
|
enum File_Error(* | File_FindFirst )(const char_const16_t *path, int *findHandle, char_const16_t *name, struct File_FindInfo *findInfoBuf) wu cstr(1) ro(1) wo(2) wo(3) wo(4) |
|
enum File_Error(* | File_FindNext )(int findHandle, char_const16_t *name, struct File_FindInfo *findInfoBuf) wu wo(2) wo(3) |
|
enum File_Error(* | File_Fstat )(int fd, struct File_Stat *buf) wu wo(2) |
|
enum File_Error(* | File_GetAddr )(int fd, int offset, const void **addr) wu wo(3) |
|
int(* | File_Lseek )(int fd, int offset, enum File_Whence whence) wu |
|
enum File_Error(* | File_Mkdir )(const char *path) wu cstr(1) ro(1) |
|
int(* | File_Open )(const char *path, int flags) wu cstr(1) ro(1) |
|
int(* | File_Read )(int fd, void *buf, int count) wu wo(2 |
|
int(*) enum File_Error(* | File_Remove )(const char *path) cstr(1) ro(1) |
|
enum File_Error(* | File_Rename )(const char *oldPath, const char *newPath) wu cstr(1) cstr(2) ro(1) ro(2) |
|
enum File_Error(* | File_Stat )(const char *path, struct File_Stat *buf) wu cstr(1) ro(1) wo(2) |
|
int(* | File_Write )(int fd, const void *buf, int count) wu ro(2 |
|
Functions for interacting with the calculator's file system.
Provides an API similar to that of Unix.
The storage which appears when the calculator is attached to a PC is found under the path \\fls0\
(remember to escape the \
in strings!).
Example: reading 256 bytes from a file called test.txt
from the USB flash
if (fd < 0) {
goto exit;
}
uint8_t buf[256];
if (ret < 0) {
goto exit;
}
if (ret < 0) {
}
exit:
File_Open
Definition file.h:135
@ FILE_OPEN_READ
Open the file as readable.
Definition file.h:137
enum File_Error(* File_Close)(int fd)
int(* File_Read)(int fd, void *buf, int count) wu wo(2
Example: writing 16 bytes to a non-existant file called f.bin
in a folder test
in the USB flash
if (fd < 0) {
goto exit;
}
uint8_t buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF};
if (ret < 0) {
goto exit;
}
if (ret < 0) {
}
exit:
@ FILE_OPEN_CREATE
Create the file, if it does not already exist.
Definition file.h:141
@ FILE_OPEN_WRITE
Open the file as writable.
Definition file.h:139
int(* File_Write)(int fd, const void *buf, int count) wu ro(2
struct __attribute__ |
( |
(packed) |
| ) |
|
Information about a file/directory, as returned from findFirst or findNext.
The type of entry which was located.
The size of the entry, in bytes. If the entry is a directory, size
is zero.
enum File_Error(* File_FindFirst) (const char_const16_t *path, int *findHandle, char_const16_t *name, struct File_FindInfo *findInfoBuf) wu cstr(1) ro(1) wo(2) wo(3) wo(4) |
( |
const char_const16_t * |
path, |
|
|
int * |
findHandle, |
|
|
char_const16_t * |
name, |
|
|
struct File_FindInfo * |
findInfoBuf |
|
) |
| |
|
extern |
Starts a find operation, locating files matching a specific path.
Can be used to list the contents of a directory by using a wildcard. For example, passing the path L"\\fls0\\*"
or L"\\fls0\\*.*"
matches all files and directories on the calculator's flash (not recursive, though).
To find the next file/directory which matches the path, call File_FindNext, passing in the find handle returned by this function. Ensure the find handle is closed using File_FindClose when the find operation is finished. Bad things happen if the handle is not closed.
- Parameters
-
[in] | path | The path to search. May contain wildcards. |
[out] | findHandle | The find handle created. Must be closed when the find operation is finished. |
[out] | name | The name of the file/directory found. |
[out] | findInfoBuf | Information about the found file. |
- Returns
- 0 on success, or a negative error code on failure.