Skip to content

Commit

Permalink
Workaround OCaml PR#8857 in Path.touch
Browse files Browse the repository at this point in the history
Signed-off-by: David Allsopp <[email protected]>
  • Loading branch information
dra27 committed Feb 13, 2021
1 parent e156482 commit 71a1f58
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/stdune/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1195,9 +1195,19 @@ let touch ?(create = true) p =
| In_build_dir k ->
Kind.to_string (Kind.append_local (Fdecl.get Build.build_dir) k)
in
try Unix.utimes p 0.0 0.0
with Unix.Unix_error (Unix.ENOENT, _, _) ->
if create then Unix.close (Unix.openfile p [ Unix.O_CREAT ] 0o777)
let create =
if create then
fun () ->
Unix.close (Unix.openfile p [ Unix.O_CREAT ] 0o777)
else
Fun.id
in
try Unix.utimes p 0.0 0.0 with
| Unix.Unix_error (Unix.ENOENT, _, _) -> create ()
| Unix.Unix_error (Unix.EUNKNOWNERR 0, _, _)
when Sys.win32 && not (Sys.file_exists p) ->
(* OCaml PR#8857 *)
create ()

let compare x y =
match (x, y) with
Expand Down

0 comments on commit 71a1f58

Please sign in to comment.