dir2list

generate a list of files shuffled by directory
git clone anongit@rnpnr.xyz:dir2list.git
Log | Files | Refs | Feed | README | LICENSE

Commit: b224087c9b226b9d853269dfce2bf44571722a93
Parent: 32cc84e14fcaacac528655d9cbdeb98efb7c3afd
Author: 0x766F6964
Date:   Mon,  4 May 2020 10:37:36 -0600

small readability change

Diffstat:
Mdir2list.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/dir2list.c b/dir2list.c @@ -100,15 +100,16 @@ subdir(struct node *node) if (!(dir = opendir(node->path))) die("opendir(): failed to open: %s\n", node->path); - s_len = strlen(node->path) + 2; + /* node changes in while() but we need this first path */ + s_len = strlen(node->path) + 1; s = xmalloc(s_len); - s_len = snprintf(s, s_len, "%s/", node->path); + s_len = snprintf(s, s_len, "%s", node->path); while ((ent = readdir(dir))) { - t_len = s_len + strlen(ent->d_name) + 1; + t_len = s_len + strlen(ent->d_name) + 2; t = xmalloc(t_len); - t_len = snprintf(t, t_len, "%s%s", s, ent->d_name); + t_len = snprintf(t, t_len, "%s/%s", s, ent->d_name); stat(t, &sb); if (S_ISDIR(sb.st_mode)) {