package eio_luv

  1. Overview
  2. Docs
type t
val is_open : t -> bool

is_open t is true if close hasn't been called yet.

val close : t -> unit

close t closes t.

  • raises Invalid_arg

    if t is already closed.

val of_luv : ?close_unix:bool -> sw:Eio.Std.Switch.t -> Luv.File.t -> t

of_luv ~sw fd wraps fd as an open file descriptor. This is unsafe if fd is closed directly (before or after wrapping it).

  • parameter sw

    The FD is closed when sw is released, if not closed manually first.

  • parameter close_unix

    if true (the default), calling close also closes fd.

val to_luv : t -> Luv.File.t

to_luv t returns the wrapped descriptor. This allows unsafe access to the FD.

  • raises Invalid_arg

    if t is closed.

val fstat : t -> Luv.File.Stat.t or_error

fstat fd returns the stat of fd.

val open_ : sw:Eio.Std.Switch.t -> ?mode:Luv.File.Mode.t list -> string -> Luv.File.Open_flag.t list -> t or_error
val read : ?file_offset:int64 -> t -> Luv.Buffer.t list -> Unsigned.Size_t.t or_error
val write_single : ?file_offset:int64 -> t -> Luv.Buffer.t list -> Unsigned.Size_t.t or_error

write_single t bufs performs a single write call and returns the number of bytes written, which may be less than the amount of data provided in bufs.

val write : t -> Luv.Buffer.t list -> unit or_error

write t bufs writes all the data in bufs (which may take several calls to write_single).

val realpath : string -> string or_error
val mkdir : mode:Luv.File.Mode.t list -> string -> unit or_error
val rmdir : string -> unit or_error
val readdir : string -> string list or_error

Wraps Luv.File.readdir. readdir opens and closes the directory for reading for the user.

OCaml

Innovation. Community. Security.