package containers

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module CCIO.FileSource

Sourcetype t = string

A file should be represented by its absolute path, but currently this is not enforced.

Sourceval to_string : t -> string
Sourceval make : string -> t

Build a file representation from a path (absolute or relative).

Sourceval exists : t -> bool
Sourceval is_directory : t -> bool
Sourceval remove_exn : t -> unit

remove_exn path tries to remove the file at path from the file system.

  • raises Sys_error

    if there is no file at path or access rights are wrong.

  • since 0.8
Sourceval remove : t -> unit or_error

Like remove_exn but with an error monad.

  • since 0.8
Sourceval remove_noerr : t -> unit

Like remove_exn but do not raise any exception on failure.

  • since 0.8
Sourceval read_dir : ?recurse:bool -> t -> t gen

read_dir d returns a sequence of files and directory contained in the directory d (or an empty stream if d is not a directory).

  • raises Sys_error

    in case of error (e.g. permission denied).

  • parameter recurse

    if true (default false), sub-directories are also explored.

Sourceval read_exn : t -> string

Read the content of the given file, or raises some exception.

  • since 0.16
Sourceval read : t -> string or_error

Read the content of the given file.

  • since 0.16
Sourceval append_exn : t -> string -> unit

Append the given string into the given file, possibly raising.

  • since 0.16
Sourceval append : t -> string -> unit or_error

Append the given string into the given file.

  • since 0.16
Sourceval write_exn : t -> string -> unit

Write the given string into the given file, possibly raising.

  • since 0.16
Sourceval write : t -> string -> unit or_error

Write the given string into the given file.

  • since 0.16
Sourcetype walk_item = [ `File | `Dir ] * t
Sourceval walk : t -> walk_item gen

Like read_dir (with recurse=true), this function walks a directory recursively and yields either files or directories. Is a file anything that doesn't satisfy is_directory (including symlinks, etc.)

  • raises Sys_error

    in case of error (e.g. permission denied) during iteration.

Sourceval walk_l : t -> walk_item list

Like walk but returns a list (therefore it's eager and might take some time on large directories).

  • since 1.1
Sourceval show_walk_item : walk_item -> string
Sourceval with_temp : ?temp_dir:string -> prefix:string -> suffix:string -> (string -> 'a) -> 'a

with_temp ~prefix ~suffix f will call f with the name of a new temporary file (located in temp_dir). After f returns, the file is deleted. Best to be used in combination with with_out. See Filename.temp_file.

  • since 0.17
OCaml

Innovation. Community. Security.