From: Stephen Seo Date: Thu, 18 Jul 2024 13:09:03 +0000 (+0900) Subject: Do not create archive file on failure X-Git-Tag: 1.0~50 X-Git-Url: https://git.seodisparate.com/gitweb?a=commitdiff_plain;h=72d2db378f3f786224a856a05a7da5feec81daf0;p=SimpleArchiver Do not create archive file on failure --- diff --git a/src/main.c b/src/main.c index c89443d..a478044 100644 --- a/src/main.c +++ b/src/main.c @@ -18,6 +18,13 @@ #include +#include "platforms.h" +#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \ + SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \ + SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX +#include +#endif + #include "archiver.h" #include "parser.h" @@ -78,6 +85,13 @@ int main(int argc, const char **argv) { fprintf(stderr, " %s\n", error_str); } fclose(file); +#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \ + SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \ + SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX + if (ret != SDAS_SUCCESS) { + unlink(parsed.filename); + } +#endif } else if ((parsed.flags & 3) == 2) { FILE *file = fopen(parsed.filename, "rb"); if (!file) {