blob: 3b7156f592e6f10462385eedc48d347d0d129395 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
module F = Filename
module FU = FileUtil
type t = {
components: string;
validators: string;
migrators: string;
component_definitions: string;
interface_definitions: string;
}
let relative_dirs = {
components = "components";
validators = "validators";
migrators = "migration";
component_definitions = "components";
interface_definitions = "interfaces";
}
let concat = List.fold_left F.concat ""
let make basepath conf =
let open Vyconf_config in
{
components = concat [basepath; conf.program_dir; relative_dirs.components];
validators = concat [basepath; conf.program_dir; relative_dirs.validators];
migrators = concat [basepath; conf.program_dir; relative_dirs.migrators];
component_definitions = concat [basepath; conf.data_dir; relative_dirs.component_definitions];
interface_definitions = concat [basepath; conf.data_dir; relative_dirs.interface_definitions]
}
(** Check if required directories exist
We do not try to check if they are readable at this point, it's just to fail early
if they don't even exist and we shouldn't bother trying
*)
let test dirs =
let check_dir d =
if FU.test FU.Is_dir d then ()
else raise (Failure (Printf.sprintf "%s does not exist or is not a directory" d)) in
let l = [dirs.components; dirs.validators; dirs.migrators;
dirs.component_definitions; dirs.interface_definitions] in
try
List.iter check_dir l; Ok ()
with Failure msg -> Error msg
|