diff options
author | Marvin Borner | 2021-01-08 14:51:11 +0100 |
---|---|---|
committer | Marvin Borner | 2021-01-08 14:51:11 +0100 |
commit | 01c570789d7f9ccc1521b791903c8a499b0f6323 (patch) | |
tree | e5275dbbc207db6be843df918b3944cc822d0819 /apps | |
parent | 52920b03e996cf60b2665772837bfa0f1661a430 (diff) |
Kinda working VFS implementation
Diffstat (limited to 'apps')
-rw-r--r-- | apps/cc.c | 2 | ||||
-rw-r--r-- | apps/exec.c | 3 | ||||
-rw-r--r-- | apps/files.c | 2 | ||||
-rw-r--r-- | apps/server.c | 14 |
4 files changed, 14 insertions, 7 deletions
@@ -803,7 +803,7 @@ int main(int argc, char **argv) } void *file; - if (!(file = read(*argv))) { + if (!(file = sread(*argv))) { printf("could not read file %s\n", *argv); return -1; } diff --git a/apps/exec.c b/apps/exec.c index e7cfcd8..100ce26 100644 --- a/apps/exec.c +++ b/apps/exec.c @@ -34,7 +34,8 @@ void on_submit(struct gui_event_keyboard *event, struct element *elem) strcat(final, PATH); strcat(final, inp); - if (stat(final)) { + struct stat s = { 0 }; + if (stat(final, &s) && s.size) { inp_elem->color_bg = COLOR_WHITE; exec(final, inp, arg, NULL); } else { diff --git a/apps/files.c b/apps/files.c index e21af5a..df590d9 100644 --- a/apps/files.c +++ b/apps/files.c @@ -38,7 +38,7 @@ void render_list(const char *path) gui_remove_element(list); list = gui_add_container(root, 0, 0, 100, 100, COLOR_BLACK); - struct dirent *d = read(path); + struct dirent *d = sread(path); int sum = 0; int calc = 0; diff --git a/apps/server.c b/apps/server.c index 3d3bb77..4840da3 100644 --- a/apps/server.c +++ b/apps/server.c @@ -33,11 +33,17 @@ int main() memset(buf, 0, 4096); - u32 len = 0; - if ((len = stat(path))) - len = http_response(HTTP_200, len, read(path), buf); + struct stat s_file = { 0 }; + int res_file = stat(path, &s_file); + + struct stat s_error = { 0 }; + stat(path, &s_error); + + int len; + if (res_file && s_file.size) + len = http_response(HTTP_200, s_file.size, sread(path), buf); else - len = http_response(HTTP_404, stat(ERROR), read(ERROR), buf); + len = http_response(HTTP_404, s_error.size, sread(ERROR), buf); net_send(socket, buf, len); net_close(socket); |