Module Data_file

Data files stored in the data directory.

type src =
  1. | Url of B0_std.Net.Url.t
    (*

    The type for data file sources.

    *)
type t

The type for data files.

val make : ?digest:string -> Data_dir.section -> filename:string -> src:src -> t

make section ~file ~src is a data file named file sourced from src in stored in the data directory section Data_dir.section.

val filename : t -> string

filename f is the filename of f.

val src : t -> src

src f is the source of f.

val digest : t -> string option

digest f is the digest of f (if any).

Operations

val exists : data_dir:B0_std.Fpath.t -> t -> (bool, string) Stdlib.result

exists ~data_dir f tests f for existence in data_dir.

val find : data_dir:B0_std.Fpath.t -> t -> (B0_std.Fpath.t option, string) Stdlib.result

find ~data_dir f finds f in data_dir.

val get : data_dir:B0_std.Fpath.t -> t -> (B0_std.Fpath.t, string) Stdlib.result

get ~data_dir f gets the file to f in data_dir and errors with an error message if it doesn't exist.

val download : httpc:B0_http.Http_client.t -> data_dir:B0_std.Fpath.t -> t -> (B0_std.Fpath.t, string) Stdlib.result

download ~httpc ~data_dir f downloads f to data_dir using httpc.

val ensure : ?available_log:B0_std.Log.level -> httpc:B0_http.Http_client.t -> data_dir:B0_std.Fpath.t -> t -> (B0_std.Fpath.t, string) Stdlib.result

ensure is like download but skips the download if the file exist.