mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCIO.File.with_temp for creating temporary files
This commit is contained in:
parent
03350031a3
commit
13dad5b6ac
2 changed files with 14 additions and 0 deletions
|
|
@ -329,4 +329,8 @@ module File = struct
|
|||
| `File -> "file:"
|
||||
| `Dir -> "dir:"
|
||||
) ^ f
|
||||
|
||||
let with_temp ?temp_dir ~prefix ~suffix f =
|
||||
let name = Filename.temp_file ?temp_dir prefix suffix in
|
||||
finally_ f name ~h:remove_noerr
|
||||
end
|
||||
|
|
|
|||
|
|
@ -195,4 +195,14 @@ module File : sig
|
|||
symlinks, etc.) *)
|
||||
|
||||
val show_walk_item : walk_item -> string
|
||||
|
||||
val with_temp :
|
||||
?temp_dir:string -> prefix:string -> suffix:string ->
|
||||
(string -> 'a) -> 'a
|
||||
(** [with_temp ~prefix ~suffix f] will call [f] with the name of a new
|
||||
temporary file (located in [temp_dir]).
|
||||
After [f] returns, the file is deleted. Best to be used in
|
||||
combination with {!with_out}.
|
||||
See {!Filename.temp_file}
|
||||
@since NEXT_RELEASE *)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue