Warning! this library assumes we are in a POSIX compliant OS.
fis a valid filename in a POSIX compliant OS (a path component and not a full path).
temp_file ?perm ?in_dir_name prefix suffix
Returns the name of a fresh temporary file in the temporary directory. The base name of the temporary file is formed by concatenating prefix, then a 6-digit hex number, then suffix. The temporary file is created empty. The file is guaranteed to be fresh, i.e. not already existing in the directory.
0o600(readable and writable only by the file owner)
temp_diris the same as
temp_filebut creates a temporary directory.
The name of the temporary directory:
Under Unix, the value of the
TMPDIR environment variable, or "/tmp" if the variable
is not set.
Under Windows, the value of the
TEMP environment variable, or "." if the variable
is not set.
Same as Core_filename.temp_file, but returns both the name of a fresh
temporary file, and an output channel opened (atomically) on
this file. This function is more secure than
is no risk that the temporary file will be modified (e.g. replaced
by a symbolic link) before the program opens it.
The conventional name for the parent of the current directory
.. in Unix).
concat p1 p2 returns a path equivalent to
p1 ^ "/" ^ p2.
In the resulting path p1 (resp. p2) has all its trailing (resp. leading)
"." and "/" removed. eg:
concat "a/." ".//b" => "a/b"
concat "." "b" => "./b"
concat "a" "." => "a/."
concat "a" "/b" => "a/b"
true if the file name is relative to the current
false if it is absolute (i.e. in Unix, starts
true if the file name is relative and does not start
with an explicit reference to the current directory (
../ in Unix),
false if it starts with an explicit reference
to the root directory or the current directory.
check_suffix name suff returns
true if the filename
ends with the suffix
chop_suffix name suff removes the suffix
name. The behavior is undefined if
name does not
end with the suffix
Return the given file name without its extension. The extension
is the shortest suffix starting with a period and not including
a directory separator,
.xyz for instance.
Invalid_argument if the given name does not contain
split_extension fn return the portion of the filename before the
extension and the (optional) extension.
split_extension "/foo/my_file" = ("/foo/my_file", None)
split_extension "/foo/my_file.txt" = ("/foo/my_file", Some "txt")
split_extension "/home/c.falls/my_file" = ("/home/c.falls/my_file", None)
Respects the posix semantic.
Split a file name into directory name / base file name.
concat (dirname name) (basename name) returns a file name
which is equivalent to
name. Moreover, after setting the
current directory to
dirname name (with Sys.chdir),
basename name (which is a relative file name)
designate the same file as
name before the call to Sys.chdir.
The result is not specified if the argument is not a valid file name (for example, under Unix if there is a NUL character in the string).
parts filename returns a list of path components in order. For instance:
"/"; "tmp"; "foo"; "bar"; "baz". The first component is always
either "." for relative paths or "/" for absolute ones.
of_parts parts joins a list of path components into a path. It does roughly the
parts, but they fail to be precisely mutually inverse because of
ambiguities like multiple consecutive slashes and . components.
Raises an error if given an empty list.