blob: 3f27bda94f6a1c62d0c1aac74663938e39b4ccd8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef FILE_H_
#define FILE_H_
#include <dirent.h>
#include <sys/stat.h>
#include "fat.h"
#include "nds.h"
#include "../bang.h"
#include "../types/pathbuf.h"
// 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'
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;
// Functions.
void init_nds_filesystem();
bool nds_filesystem_enabled();
// 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);
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);
#endif
|