Module CCIO.File
type t= stringA file should be represented by its absolute path, but currently this is not enforced.
val to_string : t -> stringval make : string -> tBuild a file representation from a path (absolute or relative).
val exists : t -> boolval is_directory : t -> boolval remove_exn : t -> unitremove_exn pathtries to remove the file atpathfrom the file system.- raises Sys_error
if there is no file at
pathor access rights are wrong.
- since
- 0.8
val remove_noerr : t -> unitLike
remove_exnbut do not raise any exception on failure.- since
- 0.8
val read_dir : ?recurse:bool -> t -> t genread_dir dreturns a sequence of files and directory contained in the directoryd(or an empty stream ifdis 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.
val read_exn : t -> stringRead the content of the given file, or raises some exception.
- raises Sys_error
in case of error.
- since
- 0.16
val append_exn : t -> string -> unitAppend the given string into the given file, possibly raising.
- raises Sys_error
in case of error.
- since
- 0.16
val write_exn : t -> string -> unitWrite the given string into the given file, possibly raising.
- raises Sys_error
in case of error.
- since
- 0.16
type walk_item= [ `File | `Dir ] * t
val walk : t -> walk_item genLike
read_dir(withrecurse=true), this function walks a directory recursively and yields either files or directories. Is a file anything that doesn't satisfyis_directory(including symlinks, etc.)- raises Sys_error
in case of error (e.g. permission denied) during iteration.
val walk_l : t -> walk_item listLike
walkbut returns a list (therefore it's eager and might take some time on large directories).- since
- 1.1
val show_walk_item : walk_item -> stringval with_temp : ?temp_dir:string -> prefix:string -> suffix:string -> (string -> 'a) -> 'awith_temp ~prefix ~suffix fwill callfwith the name of a new temporary file (located intemp_dir). Afterfreturns, the file is deleted. Best to be used in combination withwith_out. SeeFilename.temp_file.- since
- 0.17