From 174a145dcdf098d703ce31e0269fdc902b2a86f6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 2 May 2020 13:13:37 +0200 Subject: applet_tables: simulate force-renaming on Windows On Windows, you cannot `rename(source, target)` if `target` exists or if a file handle to `source` is still open. This patch is similar in spirit to 02958a6ee (kbuild: simulate force-renaming on Windows, 2017-02-01). Signed-off-by: Johannes Schindelin --- applets/applet_tables.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/applets/applet_tables.c b/applets/applet_tables.c index 7ba929b12..b1dafccd2 100644 --- a/applets/applet_tables.c +++ b/applets/applet_tables.c @@ -103,6 +103,9 @@ int main(int argc, char **argv) if (i < 0) return 1; dup2(i, 1); +#ifdef __MINGW32__ + close(i); +#endif /* Keep in sync with include/busybox.h! */ @@ -236,8 +239,14 @@ int main(int argc, char **argv) if (fclose(stdout)) return 1; +#ifdef __MINGW32__ + unlink(argv[1]); +#endif if (rename(tmp1, argv[1])) return 1; +#ifdef __MINGW32__ + unlink(argv[2]); +#endif if (rename(tmp2, argv[2])) return 1; return 0; -- cgit v1.2.3-55-g6feb