File system utilities and light binary reading helper functions.
More...
Go to the source code of this file.
|
| int | File_ReadAll (const char *path, u8 **out_data, size_t *out_size) |
| | Reads the entire contents of a file into a newly allocated buffer. More...
|
| |
| int | File_WriteAll (const char *path, const u8 *data, size_t size) |
| | Writes a buffer to a file, creating or overwriting it. More...
|
| |
| int | File_MkdirRecursive (const char *path) |
| | Creates a directory structure recursively (equivalent to mkdir -p). More...
|
| |
| int | File_RemoveRecursive (const char *path) |
| | Deletes a file or recursively deletes a directory. More...
|
| |
| u16 | ReadU16LE (const u8 *p) |
| | Helper to read a little-endian unsigned 16-bit value. More...
|
| |
| u32 | ReadU32LE (const u8 *p) |
| | Helper to read a little-endian unsigned 32-bit value. More...
|
| |
| int | CopyBytes (const u8 *data, size_t size, u8 **out_data, size_t *out_size) |
| | Allocates and duplicates a byte array. More...
|
| |
File system utilities and light binary reading helper functions.
◆ CopyBytes()
| int CopyBytes |
( |
const u8 * |
data, |
|
|
size_t |
size, |
|
|
u8 ** |
out_data, |
|
|
size_t * |
out_size |
|
) |
| |
Allocates and duplicates a byte array.
- Parameters
-
| data | Source data to copy. |
| size | Number of bytes to copy. |
| out_data | Pointer to the destination buffer pointer. |
| out_size | Pointer to store the size of the duplicated buffer. |
- Returns
- 0 on success; negative value on memory failure.
◆ File_MkdirRecursive()
| int File_MkdirRecursive |
( |
const char * |
path | ) |
|
Creates a directory structure recursively (equivalent to mkdir -p).
- Parameters
-
| path | Path of directory structure to create. |
- Returns
- 0 on success; negative value on failure.
◆ File_ReadAll()
| int File_ReadAll |
( |
const char * |
path, |
|
|
u8 ** |
out_data, |
|
|
size_t * |
out_size |
|
) |
| |
Reads the entire contents of a file into a newly allocated buffer.
- Parameters
-
| path | Path to the file to read. |
| out_data | Pointer to the destination buffer pointer, allocated inside this function. |
| out_size | Pointer to store the size of the read file in bytes. |
- Returns
- 0 on success; negative value on read failure.
◆ File_RemoveRecursive()
| int File_RemoveRecursive |
( |
const char * |
path | ) |
|
Deletes a file or recursively deletes a directory.
- Parameters
-
| path | Path of target file or directory. |
- Returns
- 0 on success; negative value on deletion failure.
◆ File_WriteAll()
| int File_WriteAll |
( |
const char * |
path, |
|
|
const u8 * |
data, |
|
|
size_t |
size |
|
) |
| |
Writes a buffer to a file, creating or overwriting it.
- Parameters
-
| path | Path to the file to write. |
| data | Pointer to the buffer containing data to write. |
| size | Number of bytes to write. |
- Returns
- 0 on success; negative value on write failure.
◆ ReadU16LE()
| u16 ReadU16LE |
( |
const u8 * |
p | ) |
|
Helper to read a little-endian unsigned 16-bit value.
- Parameters
-
| p | Pointer to the start bytes. |
- Returns
- The parsed u16 value.
◆ ReadU32LE()
| u32 ReadU32LE |
( |
const u8 * |
p | ) |
|
Helper to read a little-endian unsigned 32-bit value.
- Parameters
-
| p | Pointer to the start bytes. |
- Returns
- The parsed u32 value.