aboutsummaryrefslogtreecommitdiffstats
path: root/src/filesystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/filesystem.c')
-rw-r--r--src/filesystem.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index 2da77be..1521d69 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -116,3 +116,18 @@ fs_write(u8 *src, size_t n_bytes, u16 file_index, u16 offset, bool append) {
116 116
117 return n_bytes; 117 return n_bytes;
118} 118}
119
120int
121fs_read(u8 *dst, size_t n_bytes, u16 file_index, u16 offset) {
122 File *file = &filesystem.files[file_index];
123
124 // Check if the offset is within limits.
125 if (offset + n_bytes >= FILE_MAX_SIZE) {
126 return -1;
127 }
128
129 // Copy n_bytes to destination.
130 _fs_read(dst, FILE_DATA_OFFSET + FILE_MAX_SIZE * file_index + offset, n_bytes);
131
132 return n_bytes;
133}