diff options
author | jozan <jozan@noemail.net> | 2020-11-05 21:33:09 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-05 21:33:09 +0000 |
commit | afbc197cb2da674377514f72d3367e1f2b3e395c (patch) | |
tree | c814ec7c836dee720632526f5bfc972fa084fd9c | |
parent | Cleaner (diff) | |
download | unixize-afbc197cb2da674377514f72d3367e1f2b3e395c.tar.gz unixize-afbc197cb2da674377514f72d3367e1f2b3e395c.tar.bz2 unixize-afbc197cb2da674377514f72d3367e1f2b3e395c.tar.xz unixize-afbc197cb2da674377514f72d3367e1f2b3e395c.tar.zst unixize-afbc197cb2da674377514f72d3367e1f2b3e395c.zip |
Improvement, skipping "." and ".."
FossilOrigin-Name: 3b4fb60007441ace3d8c12ffbbee6e90dcf0f479068707c782fd25229eac5860
-rw-r--r-- | src/c_lfiles.c | 29 | ||||
-rw-r--r-- | 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(); |