diff --git a/src/io/CCIO.ml b/src/io/CCIO.ml index 5f2916c8..5bdc2ec8 100644 --- a/src/io/CCIO.ml +++ b/src/io/CCIO.ml @@ -73,7 +73,7 @@ let gen_flat_map f next_elem = next let with_in ?(mode=0o644) ?(flags=[]) filename f = - let ic = open_in_gen flags mode filename in + let ic = open_in_gen (Open_rdonly::flags) mode filename in try let x = f ic in close_in ic; @@ -134,8 +134,8 @@ let read_all ?(size=1024) ic = with Exit -> Bytes.sub_string !buf 0 !len -let with_out ?(mode=0o644) ?(flags=[]) filename f = - let oc = open_out_gen flags mode filename in +let with_out ?(mode=0o644) ?(flags=[Open_creat]) filename f = + let oc = open_out_gen (Open_wronly::flags) mode filename in try let x = f oc in close_out oc; @@ -145,7 +145,7 @@ let with_out ?(mode=0o644) ?(flags=[]) filename f = raise e let with_out_a ?mode ?(flags=[]) filename f = - with_out ?mode ~flags:(Open_creat::Open_append::flags) filename f + with_out ?mode ~flags:(Open_wronly::Open_creat::Open_append::flags) filename f let write_line oc s = output_string oc s; diff --git a/src/io/CCIO.mli b/src/io/CCIO.mli index e338ef16..4ca1b23b 100644 --- a/src/io/CCIO.mli +++ b/src/io/CCIO.mli @@ -69,7 +69,8 @@ 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. *) + channel is closed. + @param flags opening flags (default [[Open_rdonly]]) *) val read_chunks : ?size:int -> in_channel -> string gen (** Read the channel's content into chunks of size [size] *) @@ -92,12 +93,13 @@ val read_all : ?size:int -> in_channel -> string val with_out : ?mode:int -> ?flags:open_flag list -> string -> (out_channel -> 'a) -> 'a -(** Same as {!with_in} but for an output channel *) +(** Same as {!with_in} but for an output channel + @param flags opening flags (default [[Open_creat; Open_wronly]]) *) val with_out_a : ?mode:int -> ?flags:open_flag list -> string -> (out_channel -> 'a) -> 'a -(** Similar to {!with_out} but with the [Open_append] and [Open_creat] - flags activated *) +(** Similar to {!with_out} but with the [[Open_append; Open_creat; Open_wronly]] + flags activated, to append to the file *) val write_line : out_channel -> string -> unit (** Write the given string on the channel, followed by "\n" *)