Low-level and built-in high-level file operation API.
More...
Go to the source code of this file.
|
|
typedef struct file_descriptor_s | file_descriptor_t |
| |
|
| file_descriptor_t * | _afopen (const char *pathname, const char *mode) |
| | Open a file located at pathname.
|
| |
| file_descriptor_t * | __wfopen (const UTF16 *pathname, const UTF16 *mode) |
| | Open a file located at UTF-16-encoded pathname.
|
| |
| size_t | _fread (void *ptr, size_t size, size_t nmemb, file_descriptor_t *stream) |
| | Read nmemb data units of size size from a file.
|
| |
| size_t | _fwrite (const void *ptr, size_t size, size_t nmemb, file_descriptor_t *stream) |
| | Write nmemb data units of size size to a file.
|
| |
| int | __fseek (file_descriptor_t *stream, long offset, int whence) |
| | Seek to a specific position in an opened file.
|
| |
| long | _ftell (file_descriptor_t *stream) |
| | Return the current position of the file.
|
| |
| int | __fflush (file_descriptor_t *stream) |
| | Flush the cached writes to the file.
|
| |
| int | _fclose (file_descriptor_t *stream) |
| | Close a file.
|
| |
Low-level and built-in high-level file operation API.
◆ sys_seek_whence_e
whence values for __fseek().
| Enumerator |
|---|
| _SYS_SEEK_SET | Seek from the beginning of file.
|
| _SYS_SEEK_CUR | Seek from current offset.
|
| _SYS_SEEK_END | Seek from the end of file.
|
◆ __fflush()
| int __fflush |
( |
file_descriptor_t * |
stream | ) |
|
|
extern |
Flush the cached writes to the file.
Analogous to the fflush() function in POSIX.
- Parameters
-
| stream | Pointer reference returned by _afopen() or _wfopen(). |
- Return values
-
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
◆ __fseek()
| int __fseek |
( |
file_descriptor_t * |
stream, |
|
|
long |
offset, |
|
|
int |
whence |
|
) |
| |
|
extern |
Seek to a specific position in an opened file.
Analogous to the fseek() function in POSIX.
- Parameters
-
| stream | Pointer reference returned by _afopen() or _wfopen(). |
| offset | Seek offset. |
| whence | Treat offset as relative to start of file/current offset/end of file. |
- Return values
-
| 0 | The operation was completed successfully. |
| -1 | The operation failed with error. |
- See also
- sys_seek_whence_e
◆ __wfopen()
| file_descriptor_t * __wfopen |
( |
const UTF16 * |
pathname, |
|
|
const UTF16 * |
mode |
|
) |
| |
|
extern |
Open a file located at UTF-16-encoded pathname.
Analogous to the _wfopen() function in Windows.
- Parameters
-
| pathname | Path to the file to be opened. LFN (long filename) is supported. |
| mode | Mode. Tested modes are _BUL("rb") and _BUL("wb+"). |
- Returns
- Pointer reference to the opened file.
◆ _afopen()
| file_descriptor_t * _afopen |
( |
const char * |
pathname, |
|
|
const char * |
mode |
|
) |
| |
|
extern |
Open a file located at pathname.
Analogous to the fopen() function in POSIX and Windows.
- Parameters
-
| pathname | DOS 8.3 path to the file to be opened. |
| mode | Mode. Tested modes are "rb" and "wb+". |
- Returns
- Pointer reference to the opened file.
◆ _fclose()
| int _fclose |
( |
file_descriptor_t * |
stream | ) |
|
|
extern |
Close a file.
Analogous to the fclose() function in POSIX.
- Parameters
-
| stream | Pointer reference returned by _afopen() or _wfopen(). |
- Returns
- Unclear. Could be similar to POSIX fclose().
◆ _fread()
| size_t _fread |
( |
void * |
ptr, |
|
|
size_t |
size, |
|
|
size_t |
nmemb, |
|
|
file_descriptor_t * |
stream |
|
) |
| |
|
extern |
Read nmemb data units of size size from a file.
Analogous to the POSIX fread() function.
- Parameters
-
| ptr | Pointer reference to a buffer that will hold the data read from the file. |
| size | Size of individual data unit. |
| nmemb | Number of data units to read. |
| stream | Pointer reference returned by _afopen() or _wfopen(). |
- Returns
- Number of data units read.
◆ _ftell()
| long _ftell |
( |
file_descriptor_t * |
stream | ) |
|
|
extern |
Return the current position of the file.
Analogous to the ftell() function in POSIX.
- Parameters
-
| stream | Pointer reference returned by _afopen() or _wfopen(). |
- Returns
- Current position when successful, -1 when there's an error.
◆ _fwrite()
| size_t _fwrite |
( |
const void * |
ptr, |
|
|
size_t |
size, |
|
|
size_t |
nmemb, |
|
|
file_descriptor_t * |
stream |
|
) |
| |
|
extern |
Write nmemb data units of size size to a file.
Analogous to the fwrite() function in POSIX.
- Parameters
-
| ptr | Pointer reference to data that will be written to the file. |
| size | Size of individual data unit. |
| nmemb | Number of data units to write. |
| stream | Pointer reference returned by _afopen() or _wfopen(). |
- Returns
- Number of data units written.