pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit 2c21ea32dfdc263efdc030050d16a88f28c2dd48
parent 0561c20abeb8345867dab622822d3abf323b5fff
Author: z3bra <willyatmailoodotorg>
Date:   Tue Jan  5 18:08:24 2016

Return unlink/rmdir status in delete_content()

Diffstat:
 pm.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/pm.c b/pm.c @@ -381,11 +381,9 @@ delete_content(FILE *f) stat(file, &st); if (S_ISDIR(st.st_mode) && is_empty(file)) - rmdir(file); - else - unlink(file); + return rmdir(file); - return 0; + return unlink(file); } @@ -415,19 +413,20 @@ delete(const char *datadir, const char *rootfs, const char *name) return -1; } - delete_content(f); + if (delete_content(f) < 0) + return ERR_DELETE; + fclose(f); /* hack again */ chdir(cwd); free(cwd); - unlink(meta); + if (unlink(meta) < 0) + return ERR_DELETE; snprintf(meta, PATH_MAX, "%s/%s", datadir, name); - rmdir(meta); - - return 0; + return rmdir(meta); } @@ -520,7 +519,6 @@ main (int argc, char **argv) break; case 'd': action = ACTION_DELETE; - n = EARGF(usage(argv0)); break; case 'i': action = ACTION_INSPECT; @@ -533,7 +531,7 @@ main (int argc, char **argv) switch (action) { case ACTION_INSTALL: - while(*argv) { + while (*argv) { if ((p = pack_load(*(argv++)))) { metadata(PACKAGE_DATA, p); unpack(PACKAGE_ROOT, p->path); @@ -543,8 +541,8 @@ main (int argc, char **argv) break; case ACTION_DELETE: - if (delete(PACKAGE_DATA, PACKAGE_ROOT, n) != 0) - return ERR_DELETE; + while (*argv) + delete(PACKAGE_DATA, PACKAGE_ROOT, *argv++); break; case ACTION_INSPECT: