From 3166627f1485e2f05421fe874b2236852fe5d017 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 18 Dec 2019 13:30:57 -0500 Subject: Improved output and error handling --- archive.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'archive.c') diff --git a/archive.c b/archive.c index 19269a8..7ec9d04 100644 --- a/archive.c +++ b/archive.c @@ -14,6 +14,12 @@ int tar_extract_file(const char *archive, const char* filename, const char *dest char cmd[PATH_MAX]; sprintf(cmd, "tar xf %s -C %s %s 2>&1", archive, destination, filename); + if (exists(archive) != 0) { + fprintf(stderr, "%s :: ", archive); + fprintf(SYSERROR); + return -1; + } + shell(&proc, SHELL_OUTPUT, cmd); if (!proc) { fprintf(SYSERROR); @@ -31,6 +37,11 @@ int tar_extract_archive(const char *_archive, const char *_destination) { int status; char cmd[PATH_MAX]; + if (exists(_archive) != 0) { + fprintf(SYSERROR); + return -1; + } + char *archive = strdup(_archive); if (!archive) { fprintf(SYSERROR); -- cgit