blob: 86ca0396a798a1a066e659831e4ada459c8bfa61 (
plain) (
tree)
|
|
#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
|