diff options
author | jozan <jozan@noemail.net> | 2020-11-05 21:11:00 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-05 21:11:00 +0000 |
commit | a08a005acbca938722f7071686bb47a3729260d3 (patch) | |
tree | 555a71a626afc9a1af406259e576255276cd9f39 /src/c_lfiles.c | |
parent | Reading in progress (diff) | |
download | unixize-a08a005acbca938722f7071686bb47a3729260d3.tar.gz unixize-a08a005acbca938722f7071686bb47a3729260d3.tar.bz2 unixize-a08a005acbca938722f7071686bb47a3729260d3.tar.xz unixize-a08a005acbca938722f7071686bb47a3729260d3.tar.zst unixize-a08a005acbca938722f7071686bb47a3729260d3.zip |
Correctly parsed file names
FossilOrigin-Name: 980ba03855e22bc2773667472adb0eb0d440b8aa8519b1217c4c938109636c32
Diffstat (limited to '')
-rw-r--r-- | src/c_lfiles.c | 17 |
1 files changed, 14 insertions, 3 deletions
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 <sys/param.h> + #include <dirent.h> #include <errno.h> #include <stdio.h> @@ -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, |