package eio

  1. Overview
  2. Docs

Operations on open files.

module Unix_perm : sig ... end

Tranditional Unix permissions.

module Stat : sig ... end

Portable file stats.

type ro_ty = [
  1. | `File
  2. | Flow.source_ty
  3. | Resource.close_ty
]
type 'a ro = [> ro_ty ] as 'a Std.r

A file opened for reading.

type rw_ty = [
  1. | ro_ty
  2. | Flow.sink_ty
]
type 'a rw = [> rw_ty ] as 'a Std.r

A file opened for reading and writing.

module Pi : sig ... end
val stat : _ ro -> Stat.t

stat t returns the Stat.t record associated with t.

val size : _ ro -> Optint.Int63.t

size t returns the size of t.

val pread : _ ro -> file_offset:Optint.Int63.t -> Cstruct.t list -> int

pread t ~file_offset bufs performs a single read of t at file_offset into bufs.

It returns the number of bytes read, which may be less than the space in bufs, even if more bytes are available. Use pread_exact instead if you require the buffer to be filled.

To read at the current offset, use Flow.single_read instead.

val pread_exact : _ ro -> file_offset:Optint.Int63.t -> Cstruct.t list -> unit

pread_exact t ~file_offset bufs reads from t into bufs until bufs is full.

  • raises End_of_file

    if the buffer could not be filled.

val pwrite_single : _ rw -> file_offset:Optint.Int63.t -> Cstruct.t list -> int

pwrite_single t ~file_offset bufs performs a single write operation, writing data from bufs to location file_offset in t.

It returns the number of bytes written, which may be less than the length of bufs. In most cases, you will want to use pwrite_all instead.

val pwrite_all : _ rw -> file_offset:Optint.Int63.t -> Cstruct.t list -> unit

pwrite_all t ~file_offset bufs writes all the data in bufs to location file_offset in t.

OCaml

Innovation. Community. Security.