libdragon
dragonfs.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_DRAGONFS_H
7#define __LIBDRAGON_DRAGONFS_H
8
20#define DFS_DEFAULT_LOCATION 0
21
25#define MAX_OPEN_FILES 4
26
32#define MAX_FILENAME_LEN 243
33
37#define MAX_DIRECTORY_DEPTH 100
38
44#define DFS_ESUCCESS 0
46#define DFS_EBADINPUT -1
48#define DFS_ENOFILE -2
50#define DFS_EBADFS -3
52#define DFS_ENFILE -4
54#define DFS_EBADHANDLE -5
58// Deprecated naming
59#define DFS_ENOMEM -4
71#define FILETYPE(x) ((x) & 3)
72
78#define FLAGS_FILE 0x0
80#define FLAGS_DIR 0x1
82#define FLAGS_EOF 0x2
87#ifdef __cplusplus
88extern "C" {
89#endif
90
91int dfs_init(uint32_t base_fs_loc);
92int dfs_chdir(const char * const path);
93int dfs_dir_findfirst(const char * const path, char *buf);
94int dfs_dir_findnext(char *buf);
95
96int dfs_open(const char * const path);
97int dfs_read(void * const buf, int size, int count, uint32_t handle);
98int dfs_seek(uint32_t handle, int offset, int origin);
99int dfs_tell(uint32_t handle);
100int dfs_close(uint32_t handle);
101int dfs_eof(uint32_t handle);
102int dfs_size(uint32_t handle);
103uint32_t dfs_rom_addr(const char *path);
104
105const char *dfs_strerror(int error);
106
107#ifdef __cplusplus
108}
109#endif
110
111#endif
int dfs_seek(uint32_t handle, int offset, int origin)
Seek to an offset in the file.
Definition: dragonfs.c:839
int dfs_size(uint32_t handle)
Return the file size of an open file.
Definition: dragonfs.c:1045
int dfs_dir_findfirst(const char *const path, char *buf)
Find the first file or directory in a directory listing.
Definition: dragonfs.c:693
int dfs_chdir(const char *const path)
Change directories to the specified path.
Definition: dragonfs.c:666
int dfs_open(const char *const path)
Open a file given a path.
Definition: dragonfs.c:767
int dfs_read(void *const buf, int size, int count, uint32_t handle)
Read data from a file.
Definition: dragonfs.c:939
int dfs_init(uint32_t base_fs_loc)
Initialize the filesystem.
Definition: dragonfs.c:1371
uint32_t dfs_rom_addr(const char *path)
Return the physical address of a file (in ROM space)
Definition: dragonfs.c:1076
int dfs_dir_findnext(char *buf)
Find the next file or directory in a directory listing.
Definition: dragonfs.c:732
int dfs_tell(uint32_t handle)
Return the current offset into a file.
Definition: dragonfs.c:912
const char * dfs_strerror(int error)
Convert DFS error code into an error string.
Definition: dragonfs.c:1409
int dfs_close(uint32_t handle)
Close an already open file handle.
Definition: dragonfs.c:812
int dfs_eof(uint32_t handle)
Return whether the end of file has been reached.
Definition: dragonfs.c:1104