- Commit
- bec5a0426ee47dd49fe7c1995e4e455d125e41d8
- Parent
- f6739a32df3e1196c8093ec4915222c0c5449f7b
- Author
- Pablo <pablo-escobar@riseup.net>
- Date
Added a check for directories in the FILE command-line argument
A OCaml module for manipulating unlimited register machines
Added a check for directories in the FILE command-line argument
1 file changed, 3 insertions, 1 deletion
Status | File Name | N° Changes | Insertions | Deletions |
Modified | main.ml | 4 | 3 | 1 |
diff --git a/main.ml b/main.ml @@ -86,7 +86,9 @@ let (iters, init_m, regs_prints, filepath) : int * Urm.t * int list * string = (** Try to open the file with the contents of the program *) let file = try - open_in filepath + if Sys.is_directory filepath + then raise (Sys_error (Printf.sprintf "Is a directory: %s" filepath)) + else open_in filepath with Sys_error err -> Printf.eprintf "ERROR: %s\n" err; exit 1