diff options
Diffstat (limited to 'arm9/source/devices/file.h')
-rw-r--r-- | arm9/source/devices/file.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/arm9/source/devices/file.h b/arm9/source/devices/file.h new file mode 100644 index 0000000..86ca039 --- /dev/null +++ b/arm9/source/devices/file.h @@ -0,0 +1,52 @@ +#include <dirent.h> +#include "../types/pathbuf.h" + +// #include <stdio.h> +// #include <dirent.h> +// #include <string.h> +// #include <sys/stat.h> + +#ifndef FILE_H_ + #define FILE_H_ + + typedef struct { + bool open; // true if an entry is open + bool success; // true if the previous operation was successful + bool is_dir; // true if the open entry is a directory + bool child_is_dir; // true if the selected child is a directory + PathBuf entry; // write buffer for entry port + PathBuf action; // write buffer for action port + PathBuf path; // path of the open entry + PathBuf child_path; // path of the selected child + u32 pointer; // pointer in the open entry, whether dir or file + u32 length; // length of the open entry, whether dir or file + u32 pointer_write; // write cache for pointer + u32 length_write; // write cache for length + + DIR *dir; // structure pointing to current directory + FILE *file; // opaque ID referencing the open file + + FILE *tmpfile; // to open file and keep existing file open + struct dirent *child; // currently-selected directory child information + u32 dir_i; // index of next child to read from dir + } FileDevice; + + void init_filesystem(); + bool filesystem_enabled(); + + void fs_push_entry(FileDevice *fs, u8 byte); + void fs_push_action(FileDevice *fs, u8 byte); + bool fs_push_byte(PathBuf *buf, u8 byte); + + u8 fs_read_byte(FileDevice *fs); + void fs_write_byte(FileDevice *fs, u8 byte); + + void fs_ascend(FileDevice *fs); + void fs_descend(FileDevice *fs); + + void fs_seek(FileDevice *fs); + void fs_resize(FileDevice *fs); + + void fs_select_child(FileDevice *fs, u32 pointer); + +#endif |