We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e156482 commit 71a1f58Copy full SHA for 71a1f58
src/stdune/path.ml
@@ -1195,9 +1195,19 @@ let touch ?(create = true) p =
1195
| In_build_dir k ->
1196
Kind.to_string (Kind.append_local (Fdecl.get Build.build_dir) k)
1197
in
1198
- try Unix.utimes p 0.0 0.0
1199
- with Unix.Unix_error (Unix.ENOENT, _, _) ->
1200
- if create then Unix.close (Unix.openfile p [ Unix.O_CREAT ] 0o777)
+ let create =
+ if create then
+ fun () ->
1201
+ Unix.close (Unix.openfile p [ Unix.O_CREAT ] 0o777)
1202
+ else
1203
+ Fun.id
1204
+ in
1205
+ try Unix.utimes p 0.0 0.0 with
1206
+ | Unix.Unix_error (Unix.ENOENT, _, _) -> create ()
1207
+ | Unix.Unix_error (Unix.EUNKNOWNERR 0, _, _)
1208
+ when Sys.win32 && not (Sys.file_exists p) ->
1209
+ (* OCaml PR#8857 *)
1210
+ create ()
1211
1212
let compare x y =
1213
match (x, y) with
0 commit comments