-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
39 lines (30 loc) · 886 Bytes
/
main.c
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
#include <stdio.h>
#include "null0_api_filesystem.h"
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("Usage: %s <CART>\n", argv[0]);
return 1;
}
if (!null0_init_filesystem(argv[1])) {
return 1;
}
printf("Write-dir: %s\n", PHYSFS_getWriteDir());
char* out = "a\n";
if (!null0_file_append("log.txt", (unsigned char*)out, 2)) {
printf("Could not append to log.\n");
return 1;
}
char** i;
printf("Here are the files:\n");
for (i = null0_file_list("/"); *i != NULL; i++) {
printf(" %s\n", *i);
}
uint32_t bytesRead = 0;
unsigned char* bytes = null0_file_read("readme.txt", &bytesRead);
printf("readme.txt (%d)\n%s\n", bytesRead, bytes);
bytesRead = 0;
unsigned char* bytesLog = null0_file_read("log.txt", &bytesRead);
printf("log.txt (%d)\n%s\n", bytesRead, bytesLog);
null0_unload_filesystem();
return 0;
}