![]() |
µGFX
2.9
version 2.9
|
Module which contains operating system independent file I/O.
Functions | |
gBool | gfileExists (const char *fname) |
Check if file exists. More... | |
gBool | gfileDelete (const char *fname) |
Delete file. More... | |
gFileSize | gfileGetFilesize (const char *fname) |
Get the size of a file. More... | |
gBool | gfileRename (const char *oldname, const char *newname) |
Rename file. More... | |
GFILE * | gfileOpen (const char *fname, const char *mode) |
Open file. More... | |
void | gfileClose (GFILE *f) |
Close file. More... | |
gMemSize | gfileRead (GFILE *f, void *buf, gMemSize len) |
Read from file. More... | |
gMemSize | gfileWrite (GFILE *f, const void *buf, gMemSize len) |
Write to file. More... | |
gFileSize | gfileGetPos (GFILE *f) |
Get the current position of the read/write cursor. More... | |
gBool | gfileSetPos (GFILE *f, gFileSize pos) |
Set the position of the read/write cursor. More... | |
gFileSize | gfileGetSize (GFILE *f) |
Get the size of file. More... | |
gBool | gfileEOF (GFILE *f) |
Check for EOF. More... | |
gBool | gfileMount (char fs, const char *drive) |
Mount a logical drive (aka partition) More... | |
gBool | gfileUnmount (char fs, const char *drive) |
Unmount a logical drive (aka partition) More... | |
gBool | gfileSync (GFILE *f) |
Syncs the file object (flushes the buffer) More... | |
gfileList * | gfileOpenFileList (char fs, const char *path, gBool dirs) |
Open a file list. More... | |
const char * | gfileReadFileList (gfileList *pfl) |
Get the next file in a file list. More... | |
void | gfileCloseFileList (gfileList *pfl) |
Close a file list. More... | |
GFILE * | gfileOpenChibiOSFileStream (void *FileStreamPtr, const char *mode) |
Open file from a ChibiOS FileStream. More... | |
GFILE * | gfileOpenMemory (void *memptr, const char *mode) |
Open file from a memory pointer. More... | |
GFILE * | gfileOpenString (char *str, const char *mode) |
Open file from a null terminated C string. More... | |
GFILE Functionality to be included | |
#define | GFILE_NEED_NOAUTOMOUNT GFXOFF |
Should the filesystem not be mounted automatically. More... | |
#define | GFILE_NEED_NOAUTOSYNC GFXOFF |
Should the filesystem be synced automatically. More... | |
#define | GFILE_NEED_PRINTG GFXOFF |
Include printg, fprintg etc functions. More... | |
#define | GFILE_NEED_SCANG GFXOFF |
Include scang, fscang etc functions. More... | |
#define | GFILE_NEED_STRINGS GFXOFF |
Include the string based file functions. More... | |
#define | GFILE_NEED_STDIO GFXOFF |
Map many stdio functions to their GFILE equivalent. More... | |
#define | GFILE_NEED_USERFS GFXOFF |
Include the USER file system. More... | |
#define | GFILE_NEED_ROMFS GFXOFF |
Include the ROM file system. More... | |
#define | GFILE_NEED_RAMFS GFXOFF |
Include the RAM file system. More... | |
#define | GFILE_NEED_FATFS GFXOFF |
Include the FAT file system driver based on the FATFS library. More... | |
#define | GFILE_NEED_PETITFS GFXOFF |
Include the FAT file system driver based on the PETITFS library. More... | |
#define | GFILE_NEED_NATIVEFS GFXOFF |
Include the operating system's native file system. More... | |
#define | GFILE_NEED_CHIBIOSFS GFXOFF |
Include ChibiOS BaseFileStream support. More... | |
#define | GFILE_NEED_MEMFS GFXOFF |
Include raw memory pointer support. More... | |
#define | GFILE_NEED_FILELISTS GFXOFF |
Include support for file list functions. More... | |
GFILE Optional Parameters | |
#define | GFILE_ALLOW_FLOATS GFXOFF |
Add floating point support to printg/scang etc. More... | |
#define | GFILE_ALLOW_DEVICESPECIFIC GFXOFF |
Can the device be specified as part of the file name. More... | |
#define | GFILE_MAX_GFILES 3 |
The maximum number of open files. More... | |
#define | GFILE_FATFS_EXTERNAL_LIB GFXOFF |
TUse an external FATFS library instead of the uGFX inbuilt one. More... | |
#define | GFILE_PETITFS_EXTERNAL_LIB GFXOFF |
TUse an external PETITFS library instead of the uGFX inbuilt one. More... | |
Typedefs | |
typedef struct GFILE | GFILE |
A file pointer. More... | |
void gfileClose | ( | GFILE * | f | ) |
Close file.
Closes a file after is has been opened using gfileOpen()
[in] | f | The file |
void gfileCloseFileList | ( | gfileList * | pfl | ) |
Close a file list.
[in] | pfl | Pointer to a file list returned by gfileOpenFileList() |
gBool gfileDelete | ( | const char * | fname | ) |
Delete file.
[in] | fname | The file name |
gBool gfileEOF | ( | GFILE * | f | ) |
Check for EOF.
Checks if the cursor is at the end of the file
[in] | f | The file |
gBool gfileExists | ( | const char * | fname | ) |
Check if file exists.
[in] | fname | The file name |
gFileSize gfileGetFilesize | ( | const char * | fname | ) |
Get the size of a file.
gfileGetSize()
if the file is opened[in] | fname | The file name |
gFileSize gfileGetPos | ( | GFILE * | f | ) |
Get the current position of the read/write cursor.
[in] | f | The file |
gFileSize gfileGetSize | ( | GFILE * | f | ) |
Get the size of file.
gfileGetFilesize()
if the file is not opened[in] | f | The file |
gBool gfileMount | ( | char | fs, |
const char * | drive | ||
) |
Mount a logical drive (aka partition)
Not supported by every file system
Currently just one drive at one is supported.
[in] | fs | The file system (F for FatFS) |
[in] | drive | The logical drive prefix |
GFILE* gfileOpen | ( | const char * | fname, |
const char * | mode | ||
) |
Open file.
A file must be opened before it can be accessed
The resulting GFILE will be used for all functions that access the file.
[in] | fname | The file name |
[in] | mode | The mode. |
GFILE* gfileOpenChibiOSFileStream | ( | void * | FileStreamPtr, |
const char * | mode | ||
) |
Open file from a ChibiOS FileStream.
[in] | FileStreamPtr | The BaseFileStream (ChibiOS V2) or FileStream (ChibiOS V3) to open as a GFILE |
[in] | mode | The mode. |
gfileOpen()
. The open mode is NOT compared against the FileStream capabilities. gfileList* gfileOpenFileList | ( | char | fs, |
const char * | path, | ||
gBool | dirs | ||
) |
Open a file list.
[in] | fs | The file system (F for FatFS) |
[in] | path | Path information to pass to the file system |
[in] | dirs | Pass gTrue to get directories only, gFalse to get files only |
gfileCloseFileList()
when you have finished with the file list in order to free resources.GFILE* gfileOpenMemory | ( | void * | memptr, |
const char * | mode | ||
) |
Open file from a memory pointer.
[in] | memptr | The pointer to the memory |
[in] | mode | The mode. |
gfileOpen()
. Note there is no concept of file-size. Be careful not to overwrite other memory or to read from inaccessible sections of memory. GFILE* gfileOpenString | ( | char * | str, |
const char * | mode | ||
) |
Open file from a null terminated C string.
[in] | str | The pointer to the string or string buffer |
[in] | mode | The mode |
gfileOpen()
. Note there is no concept of file-size. Be careful not to overwrite other memory or to read from inaccessible sections of memory. gMemSize gfileRead | ( | GFILE * | f, |
void * | buf, | ||
gMemSize | len | ||
) |
Read from file.
Reads a given amount of bytes from the file
The read/write cursor will not be reset when calling this function
[in] | f | The file |
[out] | buf | The buffer in which to save the content that has been read from the file |
[in] | len | Amount of bytes to read |
const char* gfileReadFileList | ( | gfileList * | pfl | ) |
Get the next file in a file list.
[in] | pfl | Pointer to a file list returned by gfileOpenFileList() |
gfileOpenFileList()
, gfileReadFileList()
or gfileCloseFileList()
. Do not use this pointer after one of those calls.gBool gfileRename | ( | const char * | oldname, |
const char * | newname | ||
) |
Rename file.
[in] | oldname | The current file name |
[in] | newname | The new name of the file |
gBool gfileSetPos | ( | GFILE * | f, |
gFileSize | pos | ||
) |
Set the position of the read/write cursor.
[in] | f | The file |
[in] | pos | The position to which the cursor will be set |
gBool gfileSync | ( | GFILE * | f | ) |
Syncs the file object (flushes the buffer)
Not supported by every file system
[in] | f | The file |
gBool gfileUnmount | ( | char | fs, |
const char * | drive | ||
) |
Unmount a logical drive (aka partition)
Does have no effect if gfileMount()
as been called before hand
[in] | fs | The file system (F for FatFS) |
[in] | drive | The logical drive prefix |
gMemSize gfileWrite | ( | GFILE * | f, |
const void * | buf, | ||
gMemSize | len | ||
) |
Write to file.
Write a given amount of bytes to the file
The read/write cursor will not be reset when calling this function
[in] | f | The file |
[in] | buf | The buffer which contains the content that will be written to the file |
[in] | len | Amount of bytes to write |
#define GFILE_ALLOW_DEVICESPECIFIC GFXOFF |
Can the device be specified as part of the file name.
Definition at line 209 of file gfile_options.h.
#define GFILE_ALLOW_FLOATS GFXOFF |
Add floating point support to printg/scang etc.
Definition at line 200 of file gfile_options.h.
#define GFILE_FATFS_EXTERNAL_LIB GFXOFF |
TUse an external FATFS library instead of the uGFX inbuilt one.
Definition at line 231 of file gfile_options.h.
#define GFILE_MAX_GFILES 3 |
The maximum number of open files.
Definition at line 217 of file gfile_options.h.
#define GFILE_NEED_CHIBIOSFS GFXOFF |
Include ChibiOS BaseFileStream support.
Defaults to GFXOFF
gfileOpenBaseFileStream()
call to open a GFILE based on a BaseFileStream. The BaseFileStream must already be open. Definition at line 170 of file gfile_options.h.
#define GFILE_NEED_FATFS GFXOFF |
Include the FAT file system driver based on the FATFS library.
Defaults to GFXOFF
Definition at line 129 of file gfile_options.h.
#define GFILE_NEED_FILELISTS GFXOFF |
Include support for file list functions.
Defaults to GFXOFF
gfileOpenFileList()
, gfileReadFileList()
and gfileCloseFileList()
. Definition at line 188 of file gfile_options.h.
#define GFILE_NEED_MEMFS GFXOFF |
Include raw memory pointer support.
Defaults to GFXOFF
gfileOpenMemory()
call to open a GFILE based on a memory pointer. The GFILE opened appears to be of unlimited size. Definition at line 180 of file gfile_options.h.
#define GFILE_NEED_NATIVEFS GFXOFF |
Include the operating system's native file system.
Defaults to GFXOFF
Definition at line 158 of file gfile_options.h.
#define GFILE_NEED_NOAUTOMOUNT GFXOFF |
Should the filesystem not be mounted automatically.
The filesystem is normally mounted automatically if the user does not do it manually. This option turns that off so the user must manually mount the file-system first.
Defaults to GFXOFF
Definition at line 31 of file gfile_options.h.
#define GFILE_NEED_NOAUTOSYNC GFXOFF |
Should the filesystem be synced automatically.
The filesystem will automatically be synced after an open() or write() call unless this feature is disabled.
If this feature is disabled, the user should sync the filesystem himself using gfileSync()
Not all filesystems implement the syncing feature. This feature will have no effect in such a case.
Defaults to GFXOFF
Definition at line 44 of file gfile_options.h.
#define GFILE_NEED_PETITFS GFXOFF |
Include the FAT file system driver based on the PETITFS library.
Defaults to GFXOFF
Definition at line 145 of file gfile_options.h.
#define GFILE_NEED_PRINTG GFXOFF |
Include printg, fprintg etc functions.
Defaults to GFXOFF
GFILE_NEED_STRINGS
Definition at line 52 of file gfile_options.h.
#define GFILE_NEED_RAMFS GFXOFF |
Include the RAM file system.
Defaults to GFXOFF
Definition at line 116 of file gfile_options.h.
#define GFILE_NEED_ROMFS GFXOFF |
Include the ROM file system.
Defaults to GFXOFF
Definition at line 104 of file gfile_options.h.
#define GFILE_NEED_SCANG GFXOFF |
Include scang, fscang etc functions.
Defaults to GFXOFF
GFILE_NEED_STRINGS
Definition at line 60 of file gfile_options.h.
#define GFILE_NEED_STDIO GFXOFF |
Map many stdio functions to their GFILE equivalent.
Defaults to GFXOFF
Definition at line 76 of file gfile_options.h.
#define GFILE_NEED_STRINGS GFXOFF |
Include the string based file functions.
Defaults to GFXOFF
Definition at line 67 of file gfile_options.h.
#define GFILE_NEED_USERFS GFXOFF |
Include the USER file system.
Defaults to GFXOFF
Definition at line 91 of file gfile_options.h.
#define GFILE_PETITFS_EXTERNAL_LIB GFXOFF |
TUse an external PETITFS library instead of the uGFX inbuilt one.
Definition at line 241 of file gfile_options.h.