-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfsmanager.cpp
More file actions
35 lines (31 loc) · 762 Bytes
/
fsmanager.cpp
File metadata and controls
35 lines (31 loc) · 762 Bytes
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
#include "fsmanager.h"
void File::exec(uint8_t* args, uint32_t len) {
auto space = new uint8_t[get_size()];
uint8_t nread = read(0, space, get_size());
((void(*)(uint8_t*, uint32_t))space)(args, len);
delete space;
}
void FSManager::mount(char name, FileSystem* fs) {
if (count < FS_MAX) {
fss[count].fs = fs;
fss[count].name = name;
count++;
}
}
FileSystem* FSManager::get_fs(char* path, uint32_t pathlen) {
if (pathlen > 0 && path[0] != '\0') {
for (int i = 0; i < count; i++) {
if (fss[i].name = path[0]) {
return fss[i].fs;
}
}
}
return 0;
}
File* FSManager::open(char* path, uint32_t pathlen) {
if (pathlen > 2) {
auto fs = get_fs(path, pathlen);
return fs->open(path + 2);
}
return 0;
}