Better errors on nonexistant files

This commit is contained in:
John Whitington 2019-07-12 14:53:55 +01:00
parent a4882e4d76
commit 7a00d45b3e
1 changed files with 16 additions and 0 deletions

View File

@ -2380,6 +2380,14 @@ let rec get_single_pdf ?(decrypt=true) ?(fail=false) op read_lazy =
end end
in in
let warn_gs () = let warn_gs () =
begin match args.inputs with
(InFile inname, _, _, _, _, _)::_ ->
begin try ignore (close_in (open_in inname)) with _ ->
Printf.eprintf "File %s does not exist" inname;
exit 2
end
| _ -> ()
end;
Printf.eprintf "Failed to read malformed PDF file. Consider using -gs-malformed\n"; Printf.eprintf "Failed to read malformed PDF file. Consider using -gs-malformed\n";
exit 2 exit 2
in in
@ -2448,6 +2456,14 @@ let rec get_pdf_from_input_kind ?(read_lazy=false) ?(decrypt=true) ?(fail=false)
end end
in in
let warn_gs () = let warn_gs () =
begin match input with
(InFile inname, _, _, _, _, _) ->
begin try ignore (close_in (open_in inname)) with _ ->
Printf.eprintf "File %s does not exist\n" inname;
exit 2
end
| _ -> ()
end;
Printf.eprintf "Failed to read malformed PDF file. Consider using -gs-malformed\n"; Printf.eprintf "Failed to read malformed PDF file. Consider using -gs-malformed\n";
exit 2 exit 2
in in