You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
771 B

module Make (M : S.S) = struct
let fail = Utils.failwith
let check_usage () =
if Array.length Sys.argv <> 2 then
fail (Format.sprintf "usage: %s <file>" Sys.argv.(0))
let check_file_name f =
if not (Sys.file_exists f) then
fail (Format.sprintf "file %s doesn't exist" f) ;
if Sys.is_directory f then fail (Format.sprintf "file %s is a directory" f) ;
match M.expected_ext with
| None ->
()
| Some ext ->
if not (Filename.check_suffix f ext) then
fail
(Format.sprintf "file %s doesn't have the expected extension: %s" f
ext) ;
let name = Filename.chop_suffix (Filename.basename f) ext in
if String.length name = 0 then fail "file name shouldn't be empty"
end