Commit 3a5b4e76 authored by Michele Alberti's avatar Michele Alberti

Last cosmetic changes.

parent 2467fec1
......@@ -414,10 +414,12 @@ struct
match !possible_values with
| [] -> ()
| v when List.mem s v -> ()
| v -> P.L.abort "invalid input '%s' for option %s.@ \
Possible values are: %a" s name
(Pretty_utils.pp_list ~sep:",@ "
Format.pp_print_string) v);
| v ->
P.L.abort
"invalid input '%s' for option %s.@ Possible values are: %a"
s
name
(Pretty_utils.pp_list ~sep:",@ " Format.pp_print_string) v);
let accessor =
Typed_parameter.String
({ Typed_parameter.get = get_plain_string; set = set;
......@@ -476,10 +478,14 @@ struct
with
| Filepath.No_file ->
P.L.abort "%s%sfile not found: '%s'"
X.file_kind (if X.file_kind = "" then "" else " ") s
X.file_kind
(if X.file_kind = "" then "" else " ")
s
| Filepath.File_exists ->
P.L.abort "%s file already exists: '%s'"
X.file_kind (if X.file_kind = "" then "" else " ") s
X.file_kind
(if X.file_kind = "" then "" else " ")
s
in
set fp
......@@ -1229,10 +1235,14 @@ struct
with
| Fc_Filepath.No_file ->
P.L.abort "%s%sfile '%s' does not exist"
X.file_kind (if X.file_kind = "" then "" else " ") s
X.file_kind
(if X.file_kind = "" then "" else " ")
s
| Fc_Filepath.File_exists ->
P.L.abort "%s%sfile '%s' already exists"
X.file_kind (if X.file_kind = "" then "" else " ") s
X.file_kind
(if X.file_kind = "" then "" else " ")
s
end)
(struct
include X
......
......@@ -127,9 +127,10 @@ let insert base path_name =
let cwd = insert dummy (Sys.getcwd())
type existence = Must_exist | Must_not_exist | Indifferent
type existence =
| Must_exist
| Must_not_exist
| Indifferent
exception No_file
exception File_exists
......@@ -142,9 +143,12 @@ let normalize ?(existence=Indifferent) ?base_name path_name =
let base =
match base_name with
| None -> cwd
| Some b -> insert cwd b in
| Some b -> insert cwd b
in
let norm_path_name = (insert base path_name).path_name in
if norm_path_name = "" then "/" else norm_path_name
if norm_path_name = ""
then "/"
else norm_path_name
in
match existence with
| Indifferent ->
......
......@@ -27,13 +27,17 @@
NOTE: Prefer using the [Normalized] module whenever possible.
*)
type existence = Must_exist | Must_not_exist | Indifferent
(** Existence requirement on a file. *)
type existence =
| Must_exist (** File must exist. *)
| Must_not_exist (** File must not exist. *)
| Indifferent (** No requirement. *)
exception No_file
(** raised whenever no file exists and [existence] is [Must_exist]. *)
(** Raised whenever no file exists and [existence] is [Must_exist]. *)
exception File_exists
(** raised whenever some file exists and [existence] is [Must_not_exist]. *)
(** Raised whenever some file exists and [existence] is [Must_not_exist]. *)
(** Returns an absolute path leading to the given file.
The result is similar to [realpath --no-symlinks].
......@@ -46,7 +50,7 @@ exception File_exists
but [normalize] may accept them.
@modify Aluminium-20160501 optional base_name.
@modify Frama-C+dev optional existence
@modify Frama-C+dev optional existence.
*)
val normalize: ?existence:existence -> ?base_name:string -> string -> string
......@@ -95,7 +99,7 @@ module Normalized: sig
(** [of_string s] converts [s] into a normalized path.
@raise Invalid_argument if [s] is the empty string.
@modify Frama-C+dev add optional existence parameter
@modify Frama-C+dev add optional existence parameter.
*)
val of_string: ?existence:existence -> ?base_name:string -> string -> t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment