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) Stdlib.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) Stdlib.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) Stdlib.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) Stdlib.result

rename ~force ~make_path ~src dst renames src to dst.

Copying

val copy : ?rel:bool ->
?atomic:bool ->
?allow_hardlinks:bool ->
?follow_symlinks:bool ->
?prune:(Unix.stats -> string -> B0_std.Fpath.t -> bool) ->
make_path:bool ->
recurse:bool ->
src:B0_std.Fpath.t -> B0_std.Fpath.t -> (unit, string) Stdlib.result

copy ~make_path ~recurse ~src dst copies the file or file hierarchy rooted at src to dst. The function errors if dst exists. The semantics and arguments correspond to those of B0_std.Os.Dir.copy, except this function also works if src is not a directory. Note that prune is never called on src itself FIXME is that a good idea ? also FIXME this should error if src is a directory and recurse is false.

See also B0_std.Os.Dir.copy and B0_std.Os.File.copy.

File mode and stat

See also B0_std.Os.File.is_executable.

val get_mode : B0_std.Fpath.t -> (int, string) Stdlib.result

get_mode p is the file mode of p. Symbolic links are followed.

val set_mode : B0_std.Fpath.t -> int -> (unit, string) Stdlib.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) Stdlib.result

stat p is p's file information. Symbolic links are followed.

For hard links see Hard links.

val symlink : force:bool ->
make_path:bool ->
src:B0_std.Fpath.t -> B0_std.Fpath.t -> (unit, string) Stdlib.result

symlink ~force ~src p symbolically links src to p.

val symlink_link : B0_std.Fpath.t -> (B0_std.Fpath.t, string) Stdlib.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) Stdlib.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) Stdlib.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) Stdlib.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.