(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* true | _ -> false)*) (* Check directory can be opened *) let exists_dir dir = try Sys.is_directory dir with Sys_error _ -> false let check_unix_dir warn dir = if (Sys.os_type = "Win32" || Sys.os_type = "Cygwin") && (String.length dir > 2 && dir.[1] = ':' || String.contains dir '\\' || String.contains dir ';') then warn ("assuming " ^ dir ^ " to be a Unix path even if looking like a Win32 path.") let apply_subdir f path name = (* we avoid all files and subdirs starting by '.' (e.g. .svn) *) (* as well as skipped files like CVS, ... *) if ok_dirname name then let path = if path = "." then name else path//name in match try (Unix.stat path).Unix.st_kind with Unix.Unix_error _ -> Unix.S_BLK with | Unix.S_DIR -> f (FileDir (path,name)) | Unix.S_REG -> f (FileRegular name) | _ -> () let readdir dir = try Sys.readdir dir with any -> [||] let process_directory f path = Array.iter (apply_subdir f path) (readdir path) let process_subdirectories f path = let f = function FileDir (path,base) -> f path base | FileRegular _ -> () in process_directory f path