diff options
Diffstat (limited to 'sources.c')
-rw-r--r-- | sources.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -5,7 +5,7 @@ #include "maje.h" -static char **filelist = NULL; +static struct majefile **filelist = NULL; static size_t nfiles = 0; static int addfile(const char *path, const struct stat *st, int flags, struct FTW *ft) @@ -17,21 +17,24 @@ static int addfile(const char *path, const struct stat *st, int flags, struct FT } if (strcmp(path + strlen(path) - 2, ".c") == 0) { - char **tmp = realloc(filelist, sizeof(*filelist) * (nfiles + 2)); + struct majefile **tmp = realloc(filelist, sizeof(*filelist) * (nfiles + 2)); if (tmp == NULL) { return 1; } filelist = tmp; - filelist[nfiles] = strdup(path); - filelist[nfiles + 1] = NULL; + filelist[nfiles] = malloc(sizeof(*filelist[nfiles]) + strlen(path) + 1); + + filelist[nfiles]->st = *st; + strcpy(filelist[nfiles]->path, strdup(path)); + //filelist[nfiles + 1] = NULL; nfiles++; } return 0; } -char ** find_source_files(const char *dir) +struct majefile ** find_source_files(const char *dir) { nftw(dir, addfile, -1, 0); return filelist; |