Skip to content

Add missing_ok to Eio.Path.unlink #828

@vog

Description

@vog

It would be very helpful if there was a variant of Eio.Path.unlink that doesn't require the file to exist.

One possibility would be an optional missing_ok argument, similar to what we have in rmtree, e.g.:

let unlink ?(missing_ok=false) path =
  match missing_ok with
  | false -> original_unlink path
  | true ->
    try original_unlink path
    with Eio.Io (Eio.Fs.(E (Not_found _)), _) -> ()

The main difference to rmtree is that with this version one cannot accidentally delete whole directory sub trees.

Does that make sense? Would you accept a PR for that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions