From afbc197cb2da674377514f72d3367e1f2b3e395c Mon Sep 17 00:00:00 2001 From: jozan Date: Thu, 5 Nov 2020 21:33:09 +0000 Subject: Improvement, skipping "." and ".." FossilOrigin-Name: 3b4fb60007441ace3d8c12ffbbee6e90dcf0f479068707c782fd25229eac5860 --- src/c_lfiles.c | 29 +++++++++++++++++++---------- src/c_unixize.c | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/c_lfiles.c b/src/c_lfiles.c index c39cd02..53f8ad3 100644 --- a/src/c_lfiles.c +++ b/src/c_lfiles.c @@ -115,16 +115,19 @@ c_lfiles_new return (link); } -/* struct lfiles_s* */ -/* c_lfiles_duplicate(struct lfiles_s** head) */ -/* { */ -/* struct lfiles_s* dup; */ -/* struct lfiles_s* origin; */ -/* */ -/* if (head == NULL) { */ -/* return (NULL); */ -/* } */ -/* } */ +struct lfiles_s* +c_lfiles_duplicate(struct lfiles_s** head) +{ + struct lfiles_s* dup_head; + struct lfiles_s* dup_link; + struct lfiles_s* origin; + + if (*head == NULL) { + return (NULL); + } + origin = *head; + return (dup_head); +} struct lfiles_s* c_lfiles_gather(void) @@ -147,6 +150,12 @@ c_lfiles_gather(void) return (NULL); } while ((dp = readdir(dirp)) != NULL) { + if ( + strncmp(dp->d_name, ".", 2 * sizeof(char)) == 0 || + strncmp(dp->d_name, "..", 3 * sizeof(char)) == 0 + ) { + continue; + } link = c_lfiles_new(dp->d_name, dp->d_type); if (link == NULL) { u_dump_errno(); diff --git a/src/c_unixize.c b/src/c_unixize.c index 31bae1b..078423a 100644 --- a/src/c_unixize.c +++ b/src/c_unixize.c @@ -66,7 +66,7 @@ main c_get_opts(&opts, argc, argv); if (chdir((const char*)opts.dir) == -1) { - u_dump_err(); + u_dump_errno(); return (1); } og_files = c_lfiles_gather(); -- cgit v1.2.3