package plebeia

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t = Fs.cursor -> (Fs.cursor * 'a, Error.t) Stdlib.result Lwt.t

Monad for asynchronous file system operations

include Monad.S1 with type 'a t := 'a t
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val map : ('a -> 'b) -> 'a t -> 'b t
val mapM : ('a -> 'b t) -> 'a list -> 'b list t
val mapM_ : ('a -> unit t) -> 'a list -> unit t
val iterM : ('a -> unit t) -> 'a list -> unit t

alias of mapM_

val fold_leftM : ('a -> 'b -> 'a t) -> 'a -> 'b list -> 'a t
val parseM : ('a -> 'b list -> ('a * 'b list) t) -> 'a -> 'b list -> 'a t
module Infix : sig ... end
module Syntax : sig ... end
val lift : 'a Fs.Op.t -> 'a t

Convert Op monad to Op_lwt

val lift_op : 'a Fs.Op.t -> 'a t
val lift_lwt : 'a Lwt.t -> 'a t
val lift_result : ('a, Error.t) Result.t -> 'a t
val lift_result_lwt : ('a, Error.t) Result_lwt.t -> 'a t
val fail : Fs.error -> 'a t

Fail with the given error

val raw_cursor : Fs.raw_cursor t

Get the current underlying cursor

val chdir_parent : unit t

Moves the cursor up 1 directory level. If the cursor is already at the root, it does nothing.

val chdir_root : unit t

Moves the cursor up to the root directory. If the cursor is already at the root, it does nothing.

val chdir : ?dig:bool -> Fs_types.Path.t -> unit t

Moves the cursor to a sub-directory specified by the path. If dig=true, subdirectories are created if necessary.

val path : Fs_types.Path.t t

Get the current path of the cursor

File and directory access. It returns the current cursor and its view.

val set : Fs_types.Path.t -> Fs.cursor -> unit t

Set the tree pointed by the cursor at the specified path.

The path must not be empty.

Note: there is no loop detection. It is the user's responsibility not to introduce a loop by this function.

val copy : Fs_types.Path.t -> Fs_types.Path.t -> unit t

copy src dst sets the tree at src to dst. dst must not be empty.

If the copy creates a loop, the function fails.

Regular file read access.

val write : Fs_types.Path.t -> Value.t -> unit t

Create or update a regular file. Directories are created if necessary. The path must not be empty.

val rm : ?recursive:bool -> ?ignore_error:bool -> Fs_types.Path.t -> bool t

Remove a regular file or a directory, then returns Ok true. The path must not be empty.

recursive=false : fails when the target is a directory recursive=true : removes the target recursively if it is a directory ignore_error=false : fails when the target does not exist ignore_error=true : does not fail even if the target does not exist

Returns true if the target is really removed. Returns false if the target does not exist.

val rmdir : ?ignore_error:bool -> Fs_types.Path.t -> bool t

Recursive removal of a directory The path must not be empty.

ignore_error=false : fails when the target does not exist ignore_error=true : does not fail even if the target does not exist

Returns true if the target is really removed. Returns false if the target does not exist.

val compute_hash : Fs.hash t

Compute the Merkle hash of the cursor

val may_forget : unit t

Clear the memory cache of the tree under the current cursor, if it is already persisted on the disk.

val do_then : (Fs.cursor -> unit) -> 'a t -> 'a t

do_then f op executes f against the current cursor, then performs op.

val run : Fs.cursor -> 'a t -> (Fs.cursor * 'a, Error.t) Stdlib.result Lwt.t

Monad runner

val fold : 'a -> Fs_types.Path.t -> ('a -> Fs_types.Path.t -> Fs.cursor -> ([ `Continue | `Exit | `Up ] * 'a, Error.t) Stdlib.result Lwt.t) -> 'a t

folding

  • `Continue: if the item is a directory, its items are recursively folded
  • `Up: if the item is a directory, its items are skipped
  • `Exit: terminate the folding immediately and returns the accumulator as the final result of fold
val fold' : ?depth:[ `Eq of int | `Ge of int | `Gt of int | `Le of int | `Lt of int ] -> 'a -> Fs_types.Path.t -> ('a -> Fs_types.Path.t -> Fs.cursor -> ('a, Error.t) Stdlib.result Lwt.t) -> 'a t

folding with a depth specification

val ls : Fs_types.Path.t -> (Fs.name * Fs.cursor) list t

List the directory specified by the path

val ls2 : offset:int -> length:int -> Fs_types.Path.t -> (Fs.name * Fs.cursor) list t
val count : Fs_types.Path.t -> int option t

count the leaves and buds, loading nodes on demand.

count path, if path points to a Bud, it returns the number of the leaves and buds under path.

OCaml

Innovation. Community. Security.