Skip to content

Commit c70e8b6

Browse files
Merge pull request #984 from MisterDA/expose-lwt-io-delete-recursively
Expose `Lwt_io.delete_recursively`
2 parents aa9d18a + 27793da commit c70e8b6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
====== Additions ======
88

99
* Lwt.reraise an exception raising function which preserves backtraces, recommended for use in Lwt.catch (#963)
10+
* Expose Lwt_io.delete_recursively for deleting a directory and its content recursively. (#984, Antonin Décimo)
1011

1112
====== Build ======
1213

src/unix/lwt_io.mli

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,20 @@ val with_temp_dir :
543543
arguments to it. Once the temporary directory is created at [path],
544544
[with_temp_dir f] calls [f path]. When the promise returned by [f path] is
545545
resolved, [with_temp_dir f] recursively deletes the temporary directory and
546-
all its contents.
546+
all its contents by calling {!Lwt_io.delete_recursively}.
547547
548548
@since 4.4.0 *)
549549

550+
val delete_recursively : string -> unit Lwt.t
551+
(** [delete_recursively path] attempts to delete the directory [path]
552+
and all its content recursively.
553+
554+
This is likely VERY slow for directories with many files. That is probably
555+
best addressed by switching to blocking calls run inside a worker thread,
556+
i.e. with {!Lwt_preemptive}.
557+
558+
@since 5.7.0 *)
559+
550560
val open_connection :
551561
?fd : Lwt_unix.file_descr ->
552562
?in_buffer : Lwt_bytes.t -> ?out_buffer : Lwt_bytes.t ->

0 commit comments

Comments
 (0)