aboutsummaryrefslogtreecommitdiff
path: root/arm9/source/devices/file.h
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/source/devices/file.h')
-rw-r--r--arm9/source/devices/file.h77
1 files changed, 38 insertions, 39 deletions
diff --git a/arm9/source/devices/file.h b/arm9/source/devices/file.h
index f295e89..3f27bda 100644
--- a/arm9/source/devices/file.h
+++ b/arm9/source/devices/file.h
@@ -1,55 +1,54 @@
-#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
+ #include <dirent.h>
+ #include <sys/stat.h>
+ #include "fat.h"
+ #include "nds.h"
+ #include "../bang.h"
+ #include "../types/pathbuf.h"
- 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
- bool at_root; // current entry is the root directory
- } FileDevice;
+ // Bedrock file device.
+ typedef struct {
+ FILE *file; // Opaque ID referencing current file (if any)
+ // See ANSI C89 Standard, page 126
+ DIR *dir; // Structure referencing current directory (if any)
+ // See 'libnds/libs/libnds/include/sys/dirent.h:41'
+ u32 dir_i; // Index of next child to be read from current directory
+ bool is_root; // True if the current directory is the root directory.
+ struct dirent *child; // Information about selected child (file or dir)
+ // See 'libnds/libs/libnds/include/sys/dirent.h:17'
- void init_filesystem();
- bool filesystem_enabled();
+ PathBuf open; // Write buffer for open port
+ PathBuf action; // Write buffer for action port
+ PathBuf path; // Path of current entry
+ PathBuf child_path; // Path of selected child
+ u32 address; // Address into current entry (file or dir)
+ u32 length; // Length of current entry (file or dir)
+ bool length_cached; // True if length has been calculated.
+ u32 address_write; // Write cache for address
+ u32 length_write; // Write cache for length
+ bool error; // True if error occurred since last read
+ } FileDevice;
- void create_parents(u8 *path);
+ // Functions.
+ void init_nds_filesystem();
+ bool nds_filesystem_enabled();
- void fs_push_entry(FileDevice *fs, u8 byte);
+ // Methods.
+ void fs_reset(FileDevice *fs);
+ void fs_calculate_length(FileDevice *fs);
+ bool fs_get_open(FileDevice *fs);
+ bool fs_get_error(FileDevice *fs);
+ bool fs_get_type(FileDevice *fs);
+ bool fs_get_child_type(FileDevice *fs);
+ void fs_push_open(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