@@ -232,54 +232,6 @@ let rm ~directory =
232
232
Log. warn (fun f -> f " Failed to remove %s because %s" directory m);
233
233
Lwt. return_unit
234
234
235
- (* * delete_recursively code taken from Lwt. *)
236
-
237
- let win32_unlink fn =
238
- Lwt. catch
239
- (fun () -> Lwt_unix. unlink fn)
240
- (function
241
- | Unix. Unix_error (Unix. EACCES, _ , _ ) as ex ->
242
- Lwt_unix. lstat fn >> = fun {st_perm; _} ->
243
- (* Try removing the read-only attribute *)
244
- Lwt_unix. chmod fn 0o666 >> = fun () ->
245
- Lwt. catch
246
- (fun () -> Lwt_unix. unlink fn)
247
- (function _ ->
248
- (* Restore original permissions *)
249
- Lwt_unix. chmod fn st_perm >> = fun () ->
250
- Lwt. reraise ex)
251
- | ex -> Lwt. reraise ex)
252
-
253
- let unlink =
254
- if Sys. win32 then
255
- win32_unlink
256
- else
257
- Lwt_unix. unlink
258
-
259
- (* This is likely VERY slow for directories with many files. That is probably
260
- best addressed by switching to blocking calls run inside a worker thread,
261
- i.e. with Lwt_preemptive. *)
262
- let rec delete_recursively directory =
263
- Lwt_unix. files_of_directory directory
264
- |> Lwt_stream. iter_s begin fun entry ->
265
- if entry = Filename. current_dir_name ||
266
- entry = Filename. parent_dir_name then
267
- Lwt. return ()
268
- else
269
- let path = Filename. concat directory entry in
270
- Lwt_unix. lstat path >> = fun {Lwt_unix. st_kind; _} ->
271
- match st_kind with
272
- | S_DIR -> delete_recursively path
273
- | S_LNK when (Sys. win32 || Sys. cygwin) ->
274
- Lwt_unix. stat path >> = fun {Lwt_unix. st_kind; _} ->
275
- begin match st_kind with
276
- | S_DIR -> Lwt_unix. rmdir path
277
- | _ -> unlink path
278
- end
279
- | _ -> unlink path
280
- end >> = fun () ->
281
- Lwt_unix. rmdir directory
282
-
283
235
let normalise_path root_dir =
284
236
if Sys. win32 then
285
237
let vol, _ = Fpath. (v root_dir |> split_volume) in
0 commit comments