A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ocaml/ocaml/issues/12073 below:

Sys.rename directory corner cases under Windows · Issue #12073 · ocaml/ocaml · GitHub

While torturing Sys with some more multicore testing, I found two issues where the current Windows behaviour of Sys.rename differs from Linux and macOS. These have been confirmed on 4.14.0 and 5.0.0 on the MingW port.

On Linux and macOS it is OK to rename to an existing dir as long as it is empty - but not under Windows:

Sys.mkdir "foo" 0x755;
Sys.mkdir "bar" 0x755;
Sys.rename "foo" "bar"; (* OK on Linux and macOS, Sys_error "Permission denied" under Windows *)

In contrast, on Windows it is OK to rename a directory to an existing file (thus overwriting it) while this fails on Linux and macOS:

Sys.mkdir "aaa" 0x755;
let ch = open_out "bbb" in
output_string ch "hello world";
close_out ch;
Sys.rename "aaa" "bbb"; (* raises Sys_error "Not a directory" on Linux and macOS, succeeds on Windows *)

I found that there's been previous efforts to make the Windows behaviour more POSIX compatible in #1306

Looking at https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html I found

"If the old argument points to the pathname of a directory, the new argument shall not point to the pathname of a file that is not a directory. "

AFAICS, the current Windows behaviour on the second example does not follow this spec.

"If the directory named by the new argument exists, it shall be removed and old renamed to new."

Again the current Windows behaviour on the first example does not follow this spec AFAICS.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4