package eio

  1. Overview
  2. No Docs
Effect-based direct-style IO API for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

eio-1.3.tbz
sha256=8ed5c13e6689f31c85dca5f12762d84b8cc0042a7b07d3e464df6eb4b72b3dfc
sha512=46e8f817f32c3316e7f35835a136ad177a295b3306351eb2efa2386482b0169a5b19ed2925b32da2a1f10d40f083fe3d588dd401908f9fec6e4a44cd68535204

doc/eio/Eio/File/index.html

Module Eio.FileSource

Operations on open files.

Files implement the Flow APIs, which can be used for reading and writing data. This module provides additonal file-specific operations, such as seeking within a file.

To get an open file, use the functions in the Path module.

Types

Sourcemodule Unix_perm : sig ... end

Traditional Unix permissions.

Sourcemodule Stat : sig ... end

Portable file stats.

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

A file opened for reading.

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

A file opened for reading and writing.

Metadata

Sourceval stat : _ ro -> Stat.t

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

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

size t returns the size of t.

Reading and writing

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval seek : _ ro -> Optint.Int63.t -> [ `Set | `Cur | `End ] -> Optint.Int63.t

Set and/or get the current file position.

Like Unix.lseek.

Sourceval sync : _ rw -> unit

Flush file buffers to disk.

Like Unix.fsync.

Sourceval truncate : _ rw -> Optint.Int63.t -> unit

Set the length of a file.

Like Unix.ftruncate.

Provider Interface

Sourcemodule Pi : sig ... end