Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
FileSig.CONTENT_OPERATIONSSourceThis module provides functions to read and write complete files from and to strings, or working on file lines.
The type of a file from which we read: in_channel for FileChannel, string for FileString and FileGen.t for FileGen.
The type of a file to which we write: out_channel for FileChannel, string for FileString and FileGen.t for FileGen.
val read_file : in_file -> stringread_file file returns the full content of file. If the file is opened, it is opened in binary mode, no conversion is applied.
val write_file : out_file -> string -> unitwrite_file file content creates file file with content content. If the file is opened, it is opened in binary mode, no conversion is applied.
val read_subfile : in_file -> int -> int -> stringread_subfile file pos len returns a string containing len bytes read from file file at pos pos. If the file is opened, it is opened in binary mode. Raises End_of_file if the file is too short.
val read_lines : in_file -> string arrayread_lines file returns the content of file as an array of lines. If the file is opened, it is opened in text mode.
val read_lines_to_list : in_file -> string listread_lines_to_list file returns the content of file as a list of lines. If the file is opened, it is opened in text mode.
val write_lines : out_file -> string array -> unitwrite_lines file lines creates the file file from an array of lines, using FileChannel.output_line for each line.
val write_lines_of_list : out_file -> string list -> unitwrite_lines file lines creates the file file from a list of lines, using FileChannel.output_line for each line.
val read_sublines : in_file -> int -> int -> string arrayread_sublines file pos len returns at most len lines of the file file, starting at line pos. It differs from read_subfile in that it will not raise any exception if the file is too short. Note that it reads the file from beginning everytimes.
val read_sublines_to_list : in_file -> int -> int -> string listSame as read_sublines, but returns a list of strings.
val iter_blocks : (EzCompat.Bytes.t -> int -> unit) -> in_file -> unititer_blocks f file reads the content of file file, and calls f buffer len on each chunk. The buffer is reused, and only the first len bytes are from the file. Chunks have a maximal size of 32768.
val iter_lines : (string -> unit) -> in_file -> unititer_lines f file calls f line on all the lines line of the file file.
val iteri_lines : (int -> string -> unit) -> in_file -> unititeri_lines f file calls f line_num line on every line line of the file file, with line_num the line number, starting with line 0.