Move of_user_written_path to Alias0.T

This is done to avoid double check of the path being in build dir
This commit is contained in:
Rudi Grinberg 2018-05-09 08:09:32 +07:00
parent 8eba040b92
commit 78612e0649
1 changed files with 10 additions and 7 deletions

View File

@ -218,6 +218,7 @@ module Alias0 = struct
; name : string
}
val make : string -> dir:Path.t -> t
val of_user_written_path : loc:Loc.t -> Path.t -> t
end = struct
type t =
{ dir : Path.t
@ -231,6 +232,15 @@ module Alias0 = struct
; "dir", Path.sexp_of_t dir
];
{ dir; name }
let of_user_written_path ~loc path =
if not (Path.is_in_build_dir path) then
Loc.fail loc "Invalid alias!\n\
Tried to reference path outside build dir: %S"
(Path.to_string_maybe_quoted path);
{ dir = Path.parent path
; name = Path.basename path
}
end
include T
@ -238,13 +248,6 @@ module Alias0 = struct
let suffix = "-" ^ String.make 32 '0'
let of_user_written_path ~loc path =
if not (Path.is_in_build_dir path) then
Loc.fail loc "Invalid alias!\n\
Tried to reference path outside build dir: %S"
(Path.to_string_maybe_quoted path);
make ~dir:(Path.parent path) (Path.basename path)
let name t = t.name
let dir t = t.dir