IBase.Utils
recursively traverse a path for folders, returning results by a given fold function
recursively traverse a path for files, returning results by a given fold function
recursively find all files in path
with names ending in extension
Compute a 32-character hexadecimal crc using the Digest module
read a source file and return a list of lines
normalize_path_from ~root path
removes ".." and "." parts of root/path
when possible and returns the new root
and path
, eg if root = "r"
and path = "a/../../../foo/./bar"
then the result is ("../foo/bar", ".")
(in particular "r/a/../../../foo/./bar" and "./../foo/bar" represent the same file)
Flatten a/b/c as a-b-c. Special dirs .. and . are abbreviated. The separator -
can be customized.
Convert a filename to an absolute one if it is relative, and normalize "." and ".."
val filename_to_relative :
?force_full_backtrack:bool ->
?backtrack:int ->
root:string ->
string ->
string option
Convert an absolute filename to one relative to a root directory. Returns None
if filename is not under root. The backtrack level sets the maximum level of steps in the parent directories to search for a common prefix
type outfile = {
fname : string;
name of the file
*)out_c : IStdlib.IStd.Out_channel.t;
output channel
*)fmt : Stdlib.Format.formatter;
formatter for printing
*)}
type for files used for printing
val create_outfile : string -> outfile option
create an outfile for the command line
val close_outf : outfile -> unit
close an outfile
Functional fold function over all the files of a directory
Functional iter function over all the files of a directory
val with_intermediate_temp_file_out :
?retry:bool ->
string ->
f:(IStdlib.IStd.Out_channel.t -> 'a) ->
'a
like with_file_out
but uses a fresh intermediate temporary file and rename to avoid write-write races
consume and ignore all the lines from the channel until End_of_file is reached
echo the lines we get to stdout until End_of_file is reached
val out_channel_create_with_dir :
IStdlib.IStd.Filename.t ->
IStdlib.IStd.Out_channel.t
create an out channel with creating missing directories
realpath warn_on_error path
returns path with all symbolic links resolved. It caches results of previous calls to avoid expensive system calls. WARNING: If warn_on_error is false, no warning will be shown whenever an error occurs for the given path (e.g. if it does not exist).
wraps a function expecting 2 arguments in another that temporarily redirects stderr to /dev/null for the duration of the function call
rmtree path
removes path
and, if path
is a directory, recursively removes its contents. Files whose name matches the absolute paths in except
are not removed. If except
is specified then path
will only be spared if path
appears literally in except
(whereas files that are deeper will match if their absolute path is in except
).
rm_all_in_dir ?except path
removes all entries in path
/* except for the (absolute) paths in except
iterate on each entry in the directory except for "." and ".."
Hashtbl.hash only hashes the first 10 meaningful values, better_hash
uses everything.
drop at most one layer of well-balanced first and last characters satisfying drop
from the string; for instance, strip_balanced ~drop:(function | 'a' | 'x' -> true | _ -> false) "xaabax"
returns "aaba"
Returns the execution time of f
together with its result
executes f
after cding into dir
and then restores original cwd
On Linux systems, return Some x
where MemAvailable x
is in /proc/meminfo
. Returns None
in all other cases.
Parse each line of the given infer_deps.txt
file (split on tabs, assume 3 elements per line) and run f
on the third element. root
is used to interpret relative paths in the file.
Given a list of arguments return the extended list of arguments where the args in a file have been extracted
fold over each file in the given zip_filename
.