From 128651aeb8a83a6a240298b0391c2d183763ec93 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Thu, 24 Feb 2022 23:26:39 -0500 Subject: [PATCH] Use "remove" to delete files. The standard C library has a function to delete files, let's not pull in unix headers just to get "unlink" when standard C will do fine. --- src/main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main.c b/src/main.c index 73920ae..16f59dd 100644 --- a/src/main.c +++ b/src/main.c @@ -28,9 +28,7 @@ #include #include #include -#include #include -#include #include #include @@ -4774,25 +4772,27 @@ compare_and_move (const char *old_filename) if (error) goto end; - if (! equal && unlink (old_filename) != 0) { - error_printf (GOB_ERROR, 0, "Can't remove %s: %s", - old_filename, g_strerror (errno)); + if (!equal && remove(old_filename) != 0) { + error_printf(GOB_ERROR, 0, "Can't remove %s: %s", + old_filename, g_strerror (errno)); goto end; } } if (equal) { - if (unlink (new_filename) != 0) - error_printf (GOB_ERROR, 0, "Can't remove %s: %s", - new_filename, g_strerror (errno)); + if (remove(new_filename) != 0) { + error_printf(GOB_ERROR, 0, "Can't remove %s: %s", + new_filename, g_strerror(errno)); + } } else { - if (rename (new_filename, old_filename) != 0) - error_printf (GOB_ERROR, 0, "Can't rename %s to %s: %s", - new_filename, old_filename, - g_strerror (errno)); + if (rename(new_filename, old_filename) != 0) { + error_printf(GOB_ERROR, 0, "Can't rename %s to %s: %s", + new_filename, old_filename, + g_strerror(errno)); + } } - end: +end: g_free (new_filename); } -- 2.43.2