diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2020-05-02 13:13:37 +0200 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-02-21 09:51:19 +0000 |
commit | 174a145dcdf098d703ce31e0269fdc902b2a86f6 (patch) | |
tree | c6c7a61ceacb1418c788ac35a6341b9ca8ae0f3a /applets/applet_tables.c | |
parent | ddc4704db62865b5e2c0621f17cc2dc6909c1208 (diff) | |
download | busybox-w32-174a145dcdf098d703ce31e0269fdc902b2a86f6.tar.gz busybox-w32-174a145dcdf098d703ce31e0269fdc902b2a86f6.tar.bz2 busybox-w32-174a145dcdf098d703ce31e0269fdc902b2a86f6.zip |
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 <johannes.schindelin@gmx.de>
Diffstat (limited to 'applets/applet_tables.c')
-rw-r--r-- | applets/applet_tables.c | 9 |
1 files changed, 9 insertions, 0 deletions
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) | |||
103 | if (i < 0) | 103 | if (i < 0) |
104 | return 1; | 104 | return 1; |
105 | dup2(i, 1); | 105 | dup2(i, 1); |
106 | #ifdef __MINGW32__ | ||
107 | close(i); | ||
108 | #endif | ||
106 | 109 | ||
107 | /* Keep in sync with include/busybox.h! */ | 110 | /* Keep in sync with include/busybox.h! */ |
108 | 111 | ||
@@ -236,8 +239,14 @@ int main(int argc, char **argv) | |||
236 | 239 | ||
237 | if (fclose(stdout)) | 240 | if (fclose(stdout)) |
238 | return 1; | 241 | return 1; |
242 | #ifdef __MINGW32__ | ||
243 | unlink(argv[1]); | ||
244 | #endif | ||
239 | if (rename(tmp1, argv[1])) | 245 | if (rename(tmp1, argv[1])) |
240 | return 1; | 246 | return 1; |
247 | #ifdef __MINGW32__ | ||
248 | unlink(argv[2]); | ||
249 | #endif | ||
241 | if (rename(tmp2, argv[2])) | 250 | if (rename(tmp2, argv[2])) |
242 | return 1; | 251 | return 1; |
243 | return 0; | 252 | return 0; |