• en

Module OpamFilename

module Base : OpamMisc.ABSTRACT
Basenames
module Dir : OpamMisc.ABSTRACT
Directory names
val cwd : unit -> Dir.t
Return the current working directory
val rmdir : Dir.t -> unit
Remove a directory
val cleandir : Dir.t -> unit
Clean the contents of a directory.
val mkdir : Dir.t -> unit
Create a directory
val rec_dirs : Dir.t -> Dir.t list
List the sub-directory recursively
val dir_is_empty : Dir.t -> bool
val dirs : Dir.t -> Dir.t list
List the sub-directory (do not recurse)
val in_dir : Dir.t -> unit -> 'a -> 'a
Evaluate a function in a given directory
val exec : Dir.t -> ?env:(string * string) list -> ?name:string -> ?metadata:(string * string) list -> ?keep_going:bool -> string list list -> unit
Execute a list of commands in a given directory
val move_dir : src:Dir.t -> dst:Dir.t -> unit
Move a directory
val copy_dir : src:Dir.t -> dst:Dir.t -> unit
Copy a directory
val exists_dir : Dir.t -> bool
Does the directory existsb ?
val dirname_dir : Dir.t -> Dir.t
Return the parent directory
val basename_dir : Dir.t -> Base.t
Return the deeper directory name
val to_list_dir : Dir.t -> Dir.t list
Turn a full path into a list of directory names
val raw_dir : string -> Dir.t
Creation from a raw string (as http://<path>)
val with_tmp_dir : Dir.t -> 'a -> 'a
Execute a function in a temp directory
type t
ABSTRACT type
val of_string : string -> t
Create an abstract value from a string
val to_string : t -> string
Convert an abstract value to a string
val to_json : t -> OpamJson.t
Convert an abstract value to a JSON object
module Set : sig
type elt = t
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
module Map : sig
type key = t
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
type generic_file =
| D of Dir.t
| F of t
Generic filename
val create : Dir.t -> Base.t -> t
Create a filename from a Dir.t and a basename
val of_basename : Base.t -> t
Create a file from a basename and the current working directory as dirname
val raw : string -> t
Creation from a raw string (as http://<path>)
val prettify : t -> string
Prettify a filename:
  • replace /path/to/opam/foo by <opam>/foo
  • replace /path/to/home/foo by ~/foo
val prettify_dir : Dir.t -> string
Prettify a dirname.
val dirname : t -> Dir.t
Return the directory name
val basename : t -> Base.t
Return the base name
val read : t -> string
Retrieves the contents from the hard disk.
val open_in : t -> Pervasives.in_channel
Open a channel from a given file.
val open_out : t -> Pervasives.out_channel
val remove : t -> unit
Removes everything in filename if existed.
val write : t -> string -> unit
Removes everything in filename if existed, then write contents instead.
val exists : t -> bool
see Sys.file_exists
val check_suffix : t -> string -> bool
Check whether a file has a given suffix
val add_extension : t -> string -> t
Add a file extension
val chop_extension : t -> t
Remove the file extension
val rec_files : Dir.t -> t list
List all the filenames, recursively
val files : Dir.t -> t list
List all the filename. Do not recurse.
val with_contents : string -> 'a -> t -> 'a
Apply a function on the contents of a file
val copy_in : ?root:Dir.t -> t -> Dir.t -> unit
Copy a file in a directory. If root is set, copy also the sub-directories. For instance, copy_in ~root:"/foo" "/foo/bar/gni" "/toto" creates "/toto/bar/gni".
val move : src:t -> dst:t -> unit
Move a file
val is_exec : t -> bool
Is an executable ?
val copy : src:t -> dst:t -> unit
Copy a file
val install : ?exec:bool -> src:t -> dst:t -> unit -> unit
Installs a file to a destination. Optionnally set if the destination should be set executable
val extract : t -> Dir.t -> unit
Extract an archive in a given directory (it rewrites the root to match Dir.t dir if needed)
val extract_in : t -> Dir.t -> unit
Extract an archive in a given directory (which should already exists)
val extract_generic_file : generic_file -> Dir.t -> unit
Extract a generic file
val starts_with : Dir.t -> t -> bool
Check whether a filename starts by a given Dir.t
val ends_with : string -> t -> bool
Check whether a filename ends with a given suffix
val remove_prefix : Dir.t -> t -> string
Remove a prefix from a file name
val remove_suffix : Base.t -> t -> string
Remove a suffix from a filename
val download : overwrite:bool -> ?compress:bool -> t -> Dir.t -> t
download a remote file in a given directory. Return the location of the downloaded file if the download is successful. Compress activates http content compression if supported. May break on gzipped files, only use for text files
val download_as : overwrite:bool -> ?compress:bool -> t -> t -> unit
same as download, but with a specified destination filename instead of a directory
val download_iter : overwrite:bool -> t list -> Dir.t -> t
iterate downloads until one is sucessful
val patch : t -> Dir.t -> unit
Apply a patch to a directory
val digest : t -> string
Compute the MD5 digest of a file
val checksum : t -> string list
Compute the MD5 digest a file. Return the empty list if the file does not exist.
val checksum_dir : Dir.t -> string list
Compute the MD5 digest for all files in a directory.
val touch : t -> unit
Create an empty file
val chmod : t -> int -> unit
Change file permissions
val with_flock : ?read:bool -> t -> 'a -> 'b -> 'a -> 'b
File locks
val copy_files : src:Dir.t -> dst:Dir.t -> unit
copy_if_check t src dst copies all the files from one directory to another. Do nothing if OPAMDONOTCOPYFILE is set to a non-empty value.
module OP : sig
val (/) : Dir.t -> string -> Dir.t
Create a new directory
val (//) : Dir.t -> string -> t
Create a new filename
end
module Attribute : sig
Simple structure to hanle file attributes
type t
ABSTRACT type
val of_string : string -> t
Create an abstract value from a string
val to_string : t -> string
Convert an abstract value to a string
val to_json : t -> OpamJson.t
Convert an abstract value to a JSON object
module Set : sig
type elt = t
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : elt -> unit -> t -> unit
val fold : elt -> 'a -> 'a -> t -> 'a -> 'a
val for_all : elt -> bool -> t -> bool
val exists : elt -> bool -> t -> bool
val filter : elt -> bool -> t -> t
val partition : elt -> bool -> t -> (t * t)
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val max_elt : t -> elt
val choose : t -> elt
val split : elt -> t -> (t * bool * t)
val map : elt -> elt -> t -> t
auto-map
val choose_one : t -> elt
Return one element. Fail if the set is not a singleton.
val of_list : elt list -> t
Make a set from a list
val to_string : t -> string
Pretty-print a set
val to_json : t -> OpamJson.t
Return a JSON representation of the given set
val find : elt -> bool -> t -> elt
Find an element in the list
module Op : sig
val (++) : t -> t -> t
Infix set union
val (--) : t -> t -> t
Infix set difference
val (%%) : t -> t -> t
Infix set intersection
end
end
module Map : sig
type key = t
type 'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : key -> 'a option -> 'b option -> 'c option -> 'a t -> 'b t -> 'c t
val compare : 'a -> 'a -> int -> 'a t -> 'a t -> int
val equal : 'a -> 'a -> bool -> 'a t -> 'a t -> bool
val iter : key -> 'a -> unit -> 'a t -> unit
val fold : key -> 'a -> 'b -> 'b -> 'a t -> 'b -> 'b
val for_all : key -> 'a -> bool -> 'a t -> bool
val exists : key -> 'a -> bool -> 'a t -> bool
val filter : key -> 'a -> bool -> 'a t -> 'a t
val partition : key -> 'a -> bool -> 'a t -> ('a t * 'a t)
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> (key * 'a)
val max_binding : 'a t -> (key * 'a)
val choose : 'a t -> (key * 'a)
val split : key -> 'a t -> ('a t * 'a option * 'a t)
val find : key -> 'a t -> 'a
val map : 'a -> 'b -> 'a t -> 'b t
val mapi : key -> 'a -> 'b -> 'a t -> 'b t
val to_string : 'a -> string -> 'a t -> string
Pretty-printing
val to_json : 'a -> OpamJson.t -> 'a t -> OpamJson.t
Return a JSON representation of the given map.
val values : 'a t -> 'a list
Return the values in the map.
val keys : 'a t -> key list
Return the keys in the map.
val union : 'a -> 'a -> 'a -> 'a t -> 'a t -> 'a t
A key will be in the union of m1 and m2 if it is appears either m1 or m2, with the corresponding value. If a key appears in both m1 and m2, then the resulting value is built using the function given as argument.
val of_list : (key * 'a) list -> 'a t
Convert an assoc list to a map
end
val to_string_list : t -> string list
val of_string_list : string list -> t
val base : t -> Base.t
Get remote filename
val md5 : t -> string
MD5 digest of the remote file
val perm : t -> int option
File permission
val create : Base.t -> string -> int -> t
Constructor
end
val to_attribute : Dir.t -> t -> Attribute.t
Convert a filename to an attribute, relatively to a root