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.
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <getopt.h>
#include <limits.h>
#include <getopt.h>
- 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) {
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));
+ }
- 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));
+ }