From e310f1723747af57ca246c6397efebe2aa9f8dc6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 25 Apr 2018 16:18:32 +0700 Subject: [PATCH] Get rid of Path.is_file --- src/action.ml | 4 ++-- src/build_system.ml | 6 +++--- src/config.ml | 2 +- src/main.ml | 2 +- src/stdune/path.ml | 3 --- src/stdune/path.mli | 1 - src/utils.ml | 2 +- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/action.ml b/src/action.ml index e6c4fc21..4d91dcf3 100644 --- a/src/action.ml +++ b/src/action.ml @@ -649,7 +649,7 @@ module Promotion = struct let dump_db db = if Sys.file_exists "_build" then begin match db with - | [] -> if Path.is_file db_file then Path.unlink_no_err db_file + | [] -> if Path.exists db_file then Path.unlink_no_err db_file | l -> Io.write_file db_file (String.concat ~sep:"" @@ -657,7 +657,7 @@ module Promotion = struct end let load_db () = - if Path.is_file db_file then + if Path.exists db_file then Io.Sexp.load db_file ~mode:Many |> List.map ~f:File.t else diff --git a/src/build_system.ml b/src/build_system.ml index dfb9205f..3e0bd40b 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -19,7 +19,7 @@ module Promoted_to_delete = struct let add p = db := p :: !db let load () = - if Path.is_file fn then + if Path.exists fn then Io.Sexp.load fn ~mode:Many |> List.map ~f:Path.t else @@ -1123,7 +1123,7 @@ module Trace = struct let load () = let trace = Hashtbl.create 1024 in - if Path.is_file file then begin + if Path.exists file then begin let sexp = Io.Sexp.load file ~mode:Single in let bindings = let open Sexp.Of_sexp in @@ -1203,7 +1203,7 @@ let update_universe t = (* To workaround the fact that [mtime] is not precise enough on OSX *) Utils.Cached_digest.remove universe_file; let n = - if Path.is_file universe_file then + if Path.exists universe_file then Sexp.Of_sexp.int (Io.Sexp.load ~mode:Single universe_file) + 1 else 0 diff --git a/src/config.ml b/src/config.ml index b996c5ac..97565326 100644 --- a/src/config.ml +++ b/src/config.ml @@ -85,7 +85,7 @@ let load_config_file p = t (Io.Sexp.load_many_as_one p) let load_user_config_file () = - if Path.is_file user_config_file then + if Path.exists user_config_file then load_config_file user_config_file else default diff --git a/src/main.ml b/src/main.ml index 81a3004b..14fe46f9 100644 --- a/src/main.ml +++ b/src/main.ml @@ -55,7 +55,7 @@ let setup ?(log=Log.no_log) match workspace with | Some w -> w | None -> - if Path.is_file workspace_file then + if Path.exists workspace_file then Workspace.load ?x workspace_file else { merlin_context = Some "default" diff --git a/src/stdune/path.ml b/src/stdune/path.ml index ec369e39..4da893c1 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -431,9 +431,6 @@ let readdir t = Sys.readdir (to_string t) |> Array.to_list let is_directory t = try Sys.is_directory (to_string t) with Sys_error _ -> false -let is_file t = - try Sys.file_exists (to_string t) - with Sys_error _ -> false let rmdir t = Unix.rmdir (to_string t) let win32_unlink fn = try diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 1a7d6ae9..37d30150 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -127,7 +127,6 @@ val insert_after_build_dir_exn : t -> string -> t val exists : t -> bool val readdir : t -> string list val is_directory : t -> bool -val is_file : t -> bool val rmdir : t -> unit val unlink : t -> unit val unlink_no_err : t -> unit diff --git a/src/utils.ml b/src/utils.ml index f5c481a9..31c89d76 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -203,7 +203,7 @@ module Cached_digest = struct Io.write_file db_file (Sexp.to_string sexp) let load () = - if Path.is_file db_file then begin + if Path.exists db_file then begin let sexp = Io.Sexp.load db_file ~mode:Single in let bindings = let open Sexp.Of_sexp in