@@ -213,6 +213,8 @@ struct
213
213
| _ ::_ , [] -> false
214
214
| n1 ::p1 , n2 ::p2 -> n1= n2 && is_true_prefix p1 p2
215
215
216
+ let ocaml_version = Sys. (ocaml_release.major,ocaml_release.minor)
217
+
216
218
let next_state c fs =
217
219
match c with
218
220
| File_exists _path -> fs
@@ -226,17 +228,24 @@ struct
226
228
else fs
227
229
| Rename (old_path , new_path ) ->
228
230
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)
230
239
else
231
240
(match Model. find_opt fs old_path with
232
241
| None -> fs
233
242
| Some File ->
234
243
if (not (Model. mem fs new_path) || path_is_a_file fs new_path) then Model. rename fs old_path new_path else fs
235
244
| 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
240
249
(match Model. separate_path new_path with
241
250
| None -> fs
242
251
| Some (new_path_pref , new_name ) ->
@@ -315,10 +324,10 @@ struct
315
324
(match res with
316
325
| Ok () -> Model. mem fs old_path (* permits dir-to-file MingW success https://github.com/ocaml/ocaml/issues/12073 *)
317
326
| 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) ||
322
331
(* general conditions *)
323
332
(not (Model. mem fs old_path)) ||
324
333
is_true_prefix old_path new_path || (* parent-to-child *)
@@ -348,8 +357,8 @@ struct
348
357
| Readdir path , Res ((Result (Array String,Exn),_ ), res ) ->
349
358
(match res with
350
359
| 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)
353
362
then array_of_subdir = [||]
354
363
else
355
364
(Model. mem fs path && path_is_a_dir fs path &&
0 commit comments