Module B0_std.Os.Path

module Path: sig .. end
File system path operations.

These functions operate on files and directories equally. Specific function operating on either kind of path are in the B0_std.Os.File and B0_std.Os.Dir modules.



Existence


val exists : B0_std.Fpath.t -> (bool, string) Pervasives.result
exists p is Ok true if p exists in the file system and Ok false otherwise. Symbolic links are followed.
val must_exist : B0_std.Fpath.t -> (unit, string) Pervasives.result
must_exist p is Ok () if p exists in the file system and an error otherwise. Symbolic links are followed.

Deleting and renaming


val delete : recurse:bool -> B0_std.Fpath.t -> (bool, string) Pervasives.result
delete ~recurse p deletes p from the file system. If p is a symbolic link this only deletes the link, not the linked object. If recurse is true and p is a non-empty directory, no error occurs, its contents is recursively deleted. The result is: See also B0_std.Os.File.delete.
val rename : force:bool ->
make_path:bool ->
src:B0_std.Fpath.t -> B0_std.Fpath.t -> (unit, string) Pervasives.result
rename ~force ~make_path ~src dst renames src to dst.

File mode and stat

See also B0_std.Os.File.is_executable.

val get_mode : B0_std.Fpath.t -> (int, string) Pervasives.result
get_mode p is the file mode of p. Symbolic links are followed.
val set_mode : B0_std.Fpath.t -> int -> (unit, string) Pervasives.result
set_mode file p sets the file mode of file to p. Symbolic links are followed.
val stat : B0_std.Fpath.t -> (Unix.stats, string) Pervasives.result
stat p is p's file information. Symbolic links are followed.

Symbolic links

For hard links see Hard links.

val symlink : force:bool ->
make_path:bool ->
src:B0_std.Fpath.t -> B0_std.Fpath.t -> (unit, string) Pervasives.result
symlink ~force ~src p symbolically links src to p.
val symlink_link : B0_std.Fpath.t -> (B0_std.Fpath.t, string) Pervasives.result
symlink_link p is Ok l if p is a symbolic link to l.
val symlink_stat : B0_std.Fpath.t -> (Unix.stats, string) Pervasives.result
symlink_stat p is like B0_std.Os.Path.stat but if p is a symlink returns information about the link itself. If p is not a symlink then this is B0_std.Os.Path.stat.

Temporary paths


type tmp_name = (string -> string, unit, string) Pervasives.format 
The type for temporary file name patterns. The string format is replaced by random hexadecimal US-ASCII characters.
val tmp : ?make_path:bool ->
?dir:B0_std.Fpath.t ->
?name:tmp_name ->
unit -> (B0_std.Fpath.t, string) Pervasives.result
tmp ~make_path ~dir name () is a file system path in dir that did not exist when the name was found. It may exist once the function returns though, prefer temporary files and directories creation functions to guarantee the creation of the temporary objects.