package containers

  1. Overview
  2. Docs
type 'a or_error = [
  1. | `Ok of 'a
  2. | `Error of string
]
type t = string

A file is always represented by its absolute path

val to_string : t -> string
val make : string -> t

Build a file representation from a path (absolute or relative)

val exists : t -> bool
val is_directory : t -> bool
val remove_exn : t -> unit

remove_exn path tries to remove the file at path from the file system.

Raises Sys_error if there is no file at path.

  • since 0.8
val remove : t -> unit or_error

Like remove_exn but with an error monad.

  • since 0.8
val remove_noerr : t -> unit

Like remove_exn but do not raise any exception on failure.

  • since 0.8
val read_dir : ?recurse:bool -> t -> t gen

read_dir d returns a sequence of files and directory contained in the directory d (or an empty stream if d is not a directory)

  • parameter recurse

    if true (default false), sub-directories are also explored

type walk_item = [ `File | `Dir ] * t
val walk : t -> walk_item gen

similar to read_dir (with recurse=true), this function walks a directory recursively and yields either files or directories. Is a file anything that doesn't satisfy is_directory (including symlinks, etc.)

val show_walk_item : walk_item -> string
OCaml

Innovation. Community. Security.