Get rid of Path.is_file

This commit is contained in:
Rudi Grinberg 2018-04-25 16:18:32 +07:00
parent 5eb444e357
commit e310f17237
7 changed files with 8 additions and 12 deletions

View File

@ -649,7 +649,7 @@ module Promotion = struct
let dump_db db = let dump_db db =
if Sys.file_exists "_build" then begin if Sys.file_exists "_build" then begin
match db with 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 -> | l ->
Io.write_file db_file Io.write_file db_file
(String.concat ~sep:"" (String.concat ~sep:""
@ -657,7 +657,7 @@ module Promotion = struct
end end
let load_db () = let load_db () =
if Path.is_file db_file then if Path.exists db_file then
Io.Sexp.load db_file ~mode:Many Io.Sexp.load db_file ~mode:Many
|> List.map ~f:File.t |> List.map ~f:File.t
else else

View File

@ -19,7 +19,7 @@ module Promoted_to_delete = struct
let add p = db := p :: !db let add p = db := p :: !db
let load () = let load () =
if Path.is_file fn then if Path.exists fn then
Io.Sexp.load fn ~mode:Many Io.Sexp.load fn ~mode:Many
|> List.map ~f:Path.t |> List.map ~f:Path.t
else else
@ -1123,7 +1123,7 @@ module Trace = struct
let load () = let load () =
let trace = Hashtbl.create 1024 in 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 sexp = Io.Sexp.load file ~mode:Single in
let bindings = let bindings =
let open Sexp.Of_sexp in 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 *) (* To workaround the fact that [mtime] is not precise enough on OSX *)
Utils.Cached_digest.remove universe_file; Utils.Cached_digest.remove universe_file;
let n = 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 Sexp.Of_sexp.int (Io.Sexp.load ~mode:Single universe_file) + 1
else else
0 0

View File

@ -85,7 +85,7 @@ let load_config_file p =
t (Io.Sexp.load_many_as_one p) t (Io.Sexp.load_many_as_one p)
let load_user_config_file () = 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 load_config_file user_config_file
else else
default default

View File

@ -55,7 +55,7 @@ let setup ?(log=Log.no_log)
match workspace with match workspace with
| Some w -> w | Some w -> w
| None -> | None ->
if Path.is_file workspace_file then if Path.exists workspace_file then
Workspace.load ?x workspace_file Workspace.load ?x workspace_file
else else
{ merlin_context = Some "default" { merlin_context = Some "default"

View File

@ -431,9 +431,6 @@ let readdir t = Sys.readdir (to_string t) |> Array.to_list
let is_directory t = let is_directory t =
try Sys.is_directory (to_string t) try Sys.is_directory (to_string t)
with Sys_error _ -> false 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 rmdir t = Unix.rmdir (to_string t)
let win32_unlink fn = let win32_unlink fn =
try try

View File

@ -127,7 +127,6 @@ val insert_after_build_dir_exn : t -> string -> t
val exists : t -> bool val exists : t -> bool
val readdir : t -> string list val readdir : t -> string list
val is_directory : t -> bool val is_directory : t -> bool
val is_file : t -> bool
val rmdir : t -> unit val rmdir : t -> unit
val unlink : t -> unit val unlink : t -> unit
val unlink_no_err : t -> unit val unlink_no_err : t -> unit

View File

@ -203,7 +203,7 @@ module Cached_digest = struct
Io.write_file db_file (Sexp.to_string sexp) Io.write_file db_file (Sexp.to_string sexp)
let load () = 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 sexp = Io.Sexp.load db_file ~mode:Single in
let bindings = let bindings =
let open Sexp.Of_sexp in let open Sexp.Of_sexp in