diff options
author | 2017-07-18 14:07:59 +0200 | |
---|---|---|
committer | 2017-07-20 15:44:13 +0200 | |
commit | 2c5cc812d37da3f03abe3a0fb8029d1c74ad7b82 (patch) | |
tree | 2af65892c72f2f13cf6144538f261aeb624f8571 /lib | |
parent | e234f3ef8161f0b30c5189c629e856af04a66340 (diff) |
coq_makefile: use System.exists_dir for better portability
Diffstat (limited to 'lib')
-rw-r--r-- | lib/coqProject_file.ml4 | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/coqProject_file.ml4 b/lib/coqProject_file.ml4 index bb3cbabbd..13de731f5 100644 --- a/lib/coqProject_file.ml4 +++ b/lib/coqProject_file.ml4 @@ -73,9 +73,6 @@ let rec post_canonize f = if dir = Filename.current_dir_name then f else post_canonize dir else f -(* Avoid Sys.is_directory raise an exception (if the file does not exists) *) -let is_directory f = Sys.file_exists f && Sys.is_directory f - (********************* parser *******************************************) exception Parsing_error of string @@ -106,6 +103,15 @@ let parse f = res ;; +(* Copy from minisys.ml, since we don't see that file here *) +let exists_dir dir = + let rec strip_trailing_slash dir = + let len = String.length dir in + if len > 0 && (dir.[len-1] = '/' || dir.[len-1] = '\\') + then strip_trailing_slash (String.sub dir 0 (len-1)) else dir in + try Sys.is_directory (strip_trailing_slash dir) with Sys_error _ -> false + + let process_cmd_line orig_dir proj args = let orig_dir = (* avoids turning foo.v in ./foo.v *) if orig_dir = "." then "" else orig_dir in @@ -173,7 +179,7 @@ let process_cmd_line orig_dir proj args = | f :: r -> let f = CUnix.correct_path f orig_dir in let proj = - if is_directory f then { proj with subdirs = proj.subdirs @ [f] } + if exists_dir f then { proj with subdirs = proj.subdirs @ [f] } else match CUnix.get_extension f with | ".v" -> { proj with v_files = proj.v_files @ [f] } | ".ml" -> { proj with ml_files = proj.ml_files @ [f] } |