From e42a53786a11e7661b04c5300ea754b32730debd Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Wed, 2 Dec 2020 15:36:48 +0100 Subject: [PATCH] add path impl for linux --- fs_linux.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 fs_linux.c diff --git a/fs_linux.c b/fs_linux.c new file mode 100644 index 0000000..237c798 --- /dev/null +++ b/fs_linux.c @@ -0,0 +1,44 @@ +/* + * fs_linux.c + * + * Created on: 20.10.2017 + * Author: julian + */ +#include "fs.h" +#include +#include + +void create_path(struct path * p, const char * fsPath) { + free_path(p); + + const char *start = fsPath, *current = fsPath; + + if (*start == '/') { + // absolute path + p->absolute = 1; + current = ++start; + } + + for (;*current != '\0'; ++current) { + if (*current == '/') { + p->entries = realloc(p->entries, sizeof(p->entries[0]) * (p->len+1)); + p->entries[p->len] = strndup(start, current-start); + + // skip delimiter + start = current+1; + p->len++; + } + } + + if (start != current) { + p->entries = realloc(p->entries, sizeof(p->entries[0]) *(p->len+1)); + p->entries[p->len] = strdup(start); + p->len++; + } +} + +FILE * path_fopen(struct path * p, const char * flags) { + // reconstruct system path + return NULL; + +}