package bos

  1. Overview
  2. Docs
Basic OS interaction for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

bos-0.2.0.tbz
sha256=8c27b2cbc89a9e7ca32ecf8b232ab5c8c91c395dc4d1916cc9ddbe8c3a8e20e8
md5=aeae7447567db459c856ee41b5a66fd2

doc/bos/Bos/OS/U/index.html

Module OS.U

Low level Unix access.

These functions simply call functions from the Unix module and replace strings with Fpath.t where appropriate. They also provide more fine grained error handling, for example OS.Path.stat converts the error to a message while stat gives you the Unix error.

Error handling

type 'a result = ('a, [ `Unix of Unix.error ]) Result.result

The type for Unix results.

val pp_error : Format.formatter -> [ `Unix of Unix.error ] -> unit

pp_error ppf e prints e on ppf.

val open_error : 'a result -> ('a, [> `Unix of Unix.error ]) Result.result

open_error r allows to combine a closed unix error variant with other variants.

val error_to_msg : 'a result -> ('a, [> Rresult.R.msg ]) Result.result

error_to_msg r converts unix errors in r to an error message.

Wrapping Unix calls

val call : ('a -> 'b) -> 'a -> 'b result

call f v is Ok (f v) but Unix.error.EINTR errors are catched and handled by retrying the call. Other errors e are catched aswell and returned as Error (`Unix e).

File system operations

val mkdir : Fpath.t -> Unix.file_perm -> unit result

mkdir is Unix.mkdir, see POSIX mkdir.

link is Unix.link, see POSIX link.

val rename : Fpath.t -> Fpath.t -> unit result

rename is Unix.rename, see POSIX rename.

val stat : Fpath.t -> Unix.stats result

stat is Unix.stat, see POSIX stat.

val lstat : Fpath.t -> Unix.stats result

lstat is Unix.lstat, see POSIX lstat.

val truncate : Fpath.t -> int -> unit result

truncate is Unix.truncate, see POSIX truncate.