texdepends/fs_linux.c

45 lines
849 B
C

/*
* fs_linux.c
*
* Created on: 20.10.2017
* Author: julian
*/
#include "fs.h"
#include <string.h>
#include <stdlib.h>
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;
}