Legend:
Library
Module
Module type
Parameter
Class
Class type
IO Utils
Simple utilities to deal with basic Input/Output tasks in a resource-safe way. For advanced IO tasks, the user is advised to use something like Lwt or Async, that are far more comprehensive.
Examples:
obtain the list of lines of a file:
# let l = CCIO.(with_in "/tmp/some_file" read_lines);;
transfer one file into another:
# CCIO.(
with_in "/tmp/input"
(fun ic ->
let chunks = read_chunks ic in
with_out ~flags:[Open_binary] ~mode:0o644 "/tmp/output"
(fun oc ->
write_gen oc chunks
)
)
) ;;
since 0.6
before0.12
was in 'containers.io', now moved into 'containers'
type'a gen = unit ->'a option
See Gen in the gen library
Input
val with_in :
?mode:int ->?flags:open_flag list->string ->(in_channel->'a)->'a
Open an input file with the given optional flag list, calls the function on the input channel. When the function raises or returns, the channel is closed.
parameterflags
opening flags (default [Open_text]). Open_rdonly is used in any cases
val read_chunks : ?size:int ->in_channel->string gen
Read the channel's content into chunks of size size