File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,11 +160,13 @@ let save ?append ~create path data =
160160 with_open_out ?append ~create path @@ fun flow ->
161161 Flow. copy_string data flow
162162
163- let unlink t =
163+ let unlink ?( missing_ok = false ) t =
164164 let (Resource. T (dir, ops), path) = t in
165165 let module X = (val (Resource. get ops Fs.Pi. Dir )) in
166166 try X. unlink dir path
167- with Exn. Io _ as ex ->
167+ with
168+ | Exn. Io (Fs. (E (Not_found _ )), _ ) when missing_ok -> ()
169+ | Exn. Io _ as ex ->
168170 let bt = Printexc. get_raw_backtrace () in
169171 Exn. reraise_with_context ex bt " removing file %a" pp t
170172
Original file line number Diff line number Diff line change @@ -183,9 +183,12 @@ val read_link : _ t -> string
183183
184184(* * {1 Other} *)
185185
186- val unlink : _ t -> unit
186+ val unlink : ? missing_ok : bool -> _ t -> unit
187187(* * [unlink t] removes directory entry [t].
188188
189+ @param missing_ok If [false] (the default), raise an {!Fs.Not_found} IO error if [t] doesn't exist.
190+ If [true], do nothing if [t] is missing.
191+
189192 Note: this cannot be used to unlink directories.
190193 Use {!rmdir} for directories. *)
191194
You can’t perform that action at this time.
0 commit comments