@@ -213,6 +213,8 @@ struct
213213 | _ ::_ , [] -> false
214214 | n1 ::p1 , n2 ::p2 -> n1= n2 && is_true_prefix p1 p2
215215
216+ let ocaml_version = Sys. (ocaml_release.major,ocaml_release.minor)
217+
216218 let next_state c fs =
217219 match c with
218220 | File_exists _path -> fs
@@ -226,17 +228,24 @@ struct
226228 else fs
227229 | Rename (old_path , new_path ) ->
228230 if is_true_prefix old_path new_path
229- then fs
231+ then (* workaround for parent-to-empty-child-dir *)
232+ (if Sys. win32 && ocaml_version > = (5 ,1 ) && path_is_an_empty_dir fs new_path
233+ then
234+ (match Model. separate_path new_path with
235+ | None -> fs
236+ | Some (new_path_pref , new_name ) ->
237+ remove fs new_path_pref new_name)
238+ else fs)
230239 else
231240 (match Model. find_opt fs old_path with
232241 | None -> fs
233242 | Some File ->
234243 if (not (Model. mem fs new_path) || path_is_a_file fs new_path) then Model. rename fs old_path new_path else fs
235244 | Some (Directory _ ) ->
236- (* temporary workaround for dir-to-empty-target-dir https://github.com/ocaml/ocaml/issues/12073 *)
237- if Sys. win32 && path_is_an_empty_dir fs new_path then fs else
238- (* temporary workaround for dir-to-file https://github.com/ocaml/ocaml/issues/12073 *)
239- if (Sys. win32 && path_is_a_file fs new_path) then
245+ (* workaround for dir-to-empty-target-dir https://github.com/ocaml/ocaml/issues/12073 *)
246+ if Sys. win32 && ocaml_version < = ( 5 , 0 ) && path_is_an_empty_dir fs new_path then fs else
247+ (* workaround for dir-to-file https://github.com/ocaml/ocaml/issues/12073 *)
248+ if (Sys. win32 && ocaml_version < = ( 5 , 0 ) && path_is_a_file fs new_path) then
240249 (match Model. separate_path new_path with
241250 | None -> fs
242251 | Some (new_path_pref , new_name ) ->
@@ -315,10 +324,10 @@ struct
315324 (match res with
316325 | Ok () -> Model. mem fs old_path (* permits dir-to-file MingW success https://github.com/ocaml/ocaml/issues/12073 *)
317326 | Error (Sys_error _ ) ->
318- (* temporary workaround for dir-to-empty-target-dir https://github.com/ocaml/ocaml/issues/12073 *)
319- (Sys. win32 && path_is_a_dir fs old_path && path_is_an_empty_dir fs new_path) ||
320- (* temporary workaround for identity regression renaming under MingW *)
321- (Sys. win32 && old_path = new_path && path_is_an_empty_dir fs new_path) ||
327+ (* workaround for dir-to-empty-target-dir https://github.com/ocaml/ocaml/issues/12073 *)
328+ (Sys. win32 && ocaml_version < = ( 5 , 0 ) && path_is_a_dir fs old_path && path_is_an_empty_dir fs new_path) ||
329+ (* workaround for identity regression renaming under MingW *)
330+ (Sys. win32 && ocaml_version < = ( 5 , 0 ) && old_path = new_path && path_is_an_empty_dir fs new_path) ||
322331 (* general conditions *)
323332 (not (Model. mem fs old_path)) ||
324333 is_true_prefix old_path new_path || (* parent-to-child *)
@@ -348,8 +357,8 @@ struct
348357 | Readdir path , Res ((Result (Array String,Exn),_ ), res ) ->
349358 (match res with
350359 | Ok array_of_subdir ->
351- (* Temporary work around for mingW, see https://github.com/ocaml/ocaml/issues/11829 *)
352- if Sys. win32 && not (Model. mem fs path)
360+ (* workaround for non-existing readdir on MinGW https://github.com/ocaml/ocaml/issues/11829 *)
361+ if Sys. win32 && ocaml_version < = ( 5 , 0 ) && not (Model. mem fs path)
353362 then array_of_subdir = [||]
354363 else
355364 (Model. mem fs path && path_is_a_dir fs path &&
0 commit comments