cleanup libdirutils

This commit is contained in:
Kyle Isom 2020-02-18 07:21:20 -08:00
parent b6c2e38bd5
commit 326750158e
3 changed files with 19 additions and 13 deletions

View File

@ -1,10 +1,13 @@
[X] goto-line [X] goto-line
[ ] text-corruption bug [X] text-corruption bug
[ ] alt-modifiers [ ] alt-modifiers
[ ] refresh-screen [ ] refresh-screen
[ ] functions -> keymapping? [ ] functions -> keymapping?
[X] rendering: need to skip over control characters like we do with tabs [X] rendering: need to skip over control characters like we do with tabs
[X] control-d -> delete [X] control-d -> delete
[ ] control-g -> exit buf prompt
[ ] load-file prompt on dirty buffer
[ ] multiple files
What would it take for ke to be your daily drives? What would it take for ke to be your daily drives?
+ C-u + C-u

View File

@ -10,8 +10,8 @@ MANDIR ?= $MANDIR
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align CFLAGS += -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align
CFLAGS += -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations CFLAGS += -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wnested-externs -Winline -Wno-long-long -Wunused-variable CFLAGS += -Wnested-externs -Winline -Wno-long-long -Wunused-variable -g
CFLAGS += -Wstrict-prototypes -Werror -std=c99 -I. -I/usr/local/include CFLAGS += -Wstrict-prototypes -Werror -std=c99 -I. -I/usr/local/include -O0
CFLAGS += OS_CFLAGS CFLAGS += OS_CFLAGS
all: $(TARGET) all: $(TARGET)

View File

@ -32,8 +32,8 @@
#include "kst/dirlist.h" #include "kst/dirlist.h"
static int _parent_exists(const char *); int _parent_exists(const char *);
static int _rmdirs(const char *); int _rmdirs(const char *);
/* /*
* Determines whether a directory exists. * Determines whether a directory exists.
@ -147,8 +147,9 @@ _rmdirs(const char *path)
char child[FILENAME_MAX + 1]; char child[FILENAME_MAX + 1];
struct dirent *dp; struct dirent *dp;
DIR *dirp; DIR *dirp;
int fail = EXIT_FAILURE; int fail = EXIT_SUCCESS;
printf("_rmdirs(%s)\n", path);
if (NULL == (dirp = opendir(path))) { if (NULL == (dirp = opendir(path))) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -162,8 +163,6 @@ _rmdirs(const char *path)
continue; continue;
} }
snprintf(child, FILENAME_MAX, "%s/%s", path, dp->d_name);
if (DT_DIR == dp->d_type) { if (DT_DIR == dp->d_type) {
fail = _rmdirs(child); fail = _rmdirs(child);
if (EXIT_FAILURE == fail) { if (EXIT_FAILURE == fail) {
@ -178,12 +177,16 @@ _rmdirs(const char *path)
} }
} }
} }
if (-1 == closedir(dirp))
if (-1 == closedir(dirp)) {
return EXIT_FAILURE; return EXIT_FAILURE;
}
if (EXIT_FAILURE == fail) { if (EXIT_FAILURE == fail) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
else if (-1 == rmdir(path)) {
if (-1 == rmdir(path)) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
else { else {