From a08a005acbca938722f7071686bb47a3729260d3 Mon Sep 17 00:00:00 2001 From: jozan Date: Thu, 5 Nov 2020 21:11:00 +0000 Subject: Correctly parsed file names FossilOrigin-Name: 980ba03855e22bc2773667472adb0eb0d440b8aa8519b1217c4c938109636c32 --- src/c_lfiles.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/c_lfiles.c') diff --git a/src/c_lfiles.c b/src/c_lfiles.c index af13a39..f39c330 100644 --- a/src/c_lfiles.c +++ b/src/c_lfiles.c @@ -45,6 +45,8 @@ * In this files are functions to handle the files linked list. */ +#include + #include #include #include @@ -99,16 +101,16 @@ c_lfiles_new { struct lfiles_s* link; - link = (struct lfiles_s*)malloc(sizeof(struct lfiles_s*)); + link = (struct lfiles_s*)malloc(sizeof(struct lfiles_s)); if (link == NULL) { return (NULL); } link->filename = strdup(filename); - link->filetype = filetype; if (link->filename == NULL) { u_memdel((void*)&link); return (NULL); } + link->filetype = filetype; link->next = NULL; return (link); } @@ -131,10 +133,19 @@ c_lfiles_gather(void) struct dirent* dp; struct lfiles_s* head; struct lfiles_s* link; + char path[MAXPATHLEN]; head = NULL; link = NULL; - dirp = opendir("."); + if (getcwd(path, MAXPATHLEN) == NULL) { + dprintf( + STDERR_FILENO, + "unixize: %s\n", + strerror(errno) + ); + return (NULL); + } + dirp = opendir(path); if (dirp == NULL) { dprintf( STDERR_FILENO, -- cgit v1.2.3