let status,obj = disambiguate_obj status obj in
status, GrafiteAst.Obj (loc,obj)
-let try_open_in ~f paths path =
+let make_absolute paths path =
let rec aux = function
- | [] -> f path
+ | [] -> ignore (Unix.stat path); path
| p :: tl ->
+ let path = p ^ "/" ^ path in
try
- f (p ^ "/" ^ path)
- with Sys_error _ -> aux tl
+ ignore (Unix.stat path); path
+ with Unix.Unix_error _ -> aux tl
in
try
aux paths
- with Sys_error _ as exc ->
- MatitaLog.error ("Unable to read " ^ path);
- MatitaLog.error ("opts.include_paths was " ^ String.concat ":" paths);
- MatitaLog.error ("current working directory is " ^ Unix.getcwd ());
- raise exc
+ with Unix.Unix_error _ as exc ->
+ command_error ("File " ^ path ^ " not found")
;;
let eval_command opts status cmd =
{status with moo_content_rev =
(GrafiteAstPp.pp_command cmd ^ "\n") :: status.moo_content_rev}
| GrafiteAst.Include (loc, path) ->
- let path = MatitaMisc.obj_file_of_script path in
- (try
- let ic = try_open_in ~f:open_in opts.include_paths path in
- let stream = Stream.of_channel ic in
- let status = ref status in
- !eval_from_stream_ref status stream (fun _ _ -> ());
- close_in ic;
- !status
- with Sys_error _ -> raise (UnableToInclude path))
+ let absolute_path = make_absolute opts.include_paths path in
+ let moopath = MatitaMisc.obj_file_of_script absolute_path in
+ let ic =
+ try open_in moopath with Sys_error _ -> raise (UnableToInclude moopath) in
+ let stream = Stream.of_channel ic in
+ let status = ref status in
+ !eval_from_stream_ref status stream (fun _ _ -> ());
+ close_in ic;
+ !status
| GrafiteAst.Set (loc, name, value) ->
let value =
if name = "baseuri" then