package spotlib

  1. Overview
  2. Docs

Some simple file content iterations and /usr/bin/test style file status checking functions.

Iterators over lines
val iter_lines_exn : string -> (string -> unit) -> unit

iter_lines_exn filename f iters f over lines of contets of filename.

Note: lines are obtained by input_line: therefore the newline chars are removed from the lines.

val iter_lines : string -> (string -> unit) -> (unit, [> `Exn of exn ]) result

iter_lines filename f iters f over lines of contets of filename.

Note: lines are obtained by input_line: therefore the newline chars are removed from the lines.

val to_lines : string -> (string list, [> `Exn of exn ]) result

to_lines filename returns the contens of the file.

Note: lines are obtained by input_line: therefore the newline chars are removed from the lines.

val to_string : string -> (string, [> `Exn of exn ]) result

to_string filename returns the contens of the file.

val open_out : string -> (out_channel -> 'a) -> 'a

open_out filename f opens filename then runs f over the opened channel. The channel is closed automatically no matter whether f terminates normally or raises an exception.

val write_lines : string -> string list -> unit
val get_inode : string -> int option

Get file inode. Works for Unix and MinGW. Cygwin? Never tried.

val equal : string -> string -> bool

Check two file names share the same inode

val contains : string -> string -> string list option

contains p1 p2 return Some compos when p2 is equal to p1 or under p1. compos is the directory components from p2 to reach p1.

If p1 is non existent, the search is performed only by comparison of path names. If p1 exists, the search is performed also with the file's inodes.

module Test : sig ... end

/usr/bin/test like file testing

OCaml

Innovation. Community. Security.