diff --git a/src/s2/asset.ml b/src/s2/asset.ml index 0c1e901..4519d76 100644 --- a/src/s2/asset.ml +++ b/src/s2/asset.ml @@ -4,15 +4,13 @@ include (val Ohlog.sublogs logger "Asset") exception Error of string * string let absolute_path path = - Unix.realpath (Printf.sprintf "assets/%s" path) + try Unix.realpath (Printf.sprintf "assets/%s" path) + with Unix.Unix_error (ENOENT, _, _) -> + raise (Error (path, "not found")) let load_file path = trace (fun m -> m "open text file %S" path); - let fd = - try Unix.openfile (absolute_path path) [O_RDONLY] 0 - with Unix.Unix_error (ENOENT, _, _) -> - raise (Error (path, "not found")) - in + let fd = Unix.openfile (absolute_path path) [O_RDONLY] 0 in let len = (Unix.fstat fd).st_size in let buf = Bytes.create len in trace (fun m -> m "length=%d" len);