|
AnimaEngine
1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
|
Implementations of filesystem utility functions. More...
#include "file_util.h"#include <errno.h>#include <ftw.h>#include <sys/stat.h>#include <sys/types.h>Macros | |
| #define | _XOPEN_SOURCE 500 |
Functions | |
| static int | File_MkdirOne (const char *path) |
| Creates a single directory. More... | |
| 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... | |
| static int | File_RemoveRecursiveCallback (const char *path, const struct stat *st, int type_flag, struct FTW *ftw_buffer) |
| Callback function used by nftw to remove individual files and directories. 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... | |
| int | CopyBytes (const u8 *data, size_t size, u8 **out_data, size_t *out_size) |
| Allocates and duplicates a byte array. More... | |
| u32 | ReadU32LE (const u8 *p) |
| Helper to read a little-endian unsigned 32-bit value. More... | |
Implementations of filesystem utility functions.
| #define _XOPEN_SOURCE 500 |
Allocates and duplicates a byte array.
| 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. |
|
static |
Creates a single directory.
| path | Directory path. |
| int File_MkdirRecursive | ( | const char * | path | ) |
Creates a directory structure recursively (equivalent to mkdir -p).
| path | Path of directory structure to create. |
| 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.
| 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. |
| int File_RemoveRecursive | ( | const char * | path | ) |
Deletes a file or recursively deletes a directory.
| path | Path of target file or directory. |
|
static |
Callback function used by nftw to remove individual files and directories.
| path | System path. |
| st | File stat pointer (unused). |
| type_flag | File type flags (unused). |
| ftw_buffer | FTW struct details (unused). |
| int File_WriteAll | ( | const char * | path, |
| const u8 * | data, | ||
| size_t | size | ||
| ) |
Writes a buffer to a file, creating or overwriting it.
| path | Path to the file to write. |
| data | Pointer to the buffer containing data to write. |
| size | Number of bytes to write. |
Helper to read a little-endian unsigned 16-bit value.
| p | Pointer to the start bytes. |