From 7d57469d2f2618959c15d7c1acce682e1b5794d3 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 9 Dec 2016 16:26:12 -0800 Subject: [PATCH] Core.Std.Filename Reviewed By: cristianoc Differential Revision: D4232427 fbshipit-source-id: 01df454 --- infer/src/base/Logging.ml | 2 +- infer/src/base/Serialization.ml | 2 +- infer/src/base/SourceFile.ml | 2 +- infer/src/base/Utils.ml | 4 ++-- infer/src/base/Utils.mli | 1 + infer/src/harness/inhabit.ml | 4 ++-- infer/src/integration/CaptureCompilationDatabase.ml | 2 +- infer/src/integration/ClangQuotes.re | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/infer/src/base/Logging.ml b/infer/src/base/Logging.ml index a95f12a73..368c0c550 100644 --- a/infer/src/base/Logging.ml +++ b/infer/src/base/Logging.ml @@ -56,7 +56,7 @@ let set_log_file_identifier (current_exe : CLOpt.exe) string_opt = let file = (* the command-line option takes precedence if specified *) if name <> "" then name - else Filename.temp_file ~temp_dir:exe_log_dir name_prefix suffix in + else Filename.temp_file ~in_dir:exe_log_dir name_prefix suffix in let chan = Pervasives.open_out file in let fmt = F.formatter_of_out_channel chan in (fmt, chan, file) diff --git a/infer/src/base/Serialization.ml b/infer/src/base/Serialization.ml index 2a597b591..c0b3c6f04 100644 --- a/infer/src/base/Serialization.ml +++ b/infer/src/base/Serialization.ml @@ -86,7 +86,7 @@ let create_serializer (key : key) : 'a serializer = (* support nonblocking reads and writes in parallel: *) (* write to a tmp file and use rename which is atomic *) let fname_tmp = Filename.temp_file - ~temp_dir:(Filename.dirname fname_str) (Filename.basename fname_str) ".tmp" in + ~in_dir:(Filename.dirname fname_str) (Filename.basename fname_str) ".tmp" in let outc = open_out_bin fname_tmp in Marshal.to_channel outc (key, version, value) []; close_out outc; diff --git a/infer/src/base/SourceFile.ml b/infer/src/base/SourceFile.ml index d1e8013df..bd2e2f717 100644 --- a/infer/src/base/SourceFile.ml +++ b/infer/src/base/SourceFile.ml @@ -132,7 +132,7 @@ let of_header header_file = let abs_path = to_abs_path header_file in let source_exts = ["c"; "cc"; "cpp"; "cxx"; "m"; "mm"] in let header_exts = ["h"; "hh"; "hpp"; "hxx"] in - let file_no_ext, ext_opt = Core.Std.Filename.split_extension abs_path in + let file_no_ext, ext_opt = Filename.split_extension abs_path in let file_opt = match ext_opt with | Some ext when IList.mem String.equal ext header_exts -> ( let possible_files = IList.map (fun ext -> file_no_ext ^ "." ^ ext) source_exts in diff --git a/infer/src/base/Utils.ml b/infer/src/base/Utils.ml index 4e6d28e40..e27f0081f 100644 --- a/infer/src/base/Utils.ml +++ b/infer/src/base/Utils.ml @@ -11,6 +11,7 @@ (** General utility functions and definition with global scope *) module Bool = Core.Std.Bool +module Filename = Core.Std.Filename module Int = Core.Std.Int module String = Core.Std.String @@ -572,7 +573,7 @@ let realpath_cache = Hashtbl.create 1023 let realpath path = match Hashtbl.find realpath_cache path with | exception Not_found -> ( - match Core.Std.Filename.realpath path with + match Filename.realpath path with | realpath -> Hashtbl.add realpath_cache path (Ok realpath); realpath @@ -582,7 +583,6 @@ let realpath path = (* cache failures as well *) Hashtbl.add realpath_cache path (Error (code, f, arg)); raise (Unix.Unix_error (code, f, arg)) - ) | Ok path -> path | Error (code, f, arg) -> raise (Unix.Unix_error (code, f, arg)) diff --git a/infer/src/base/Utils.mli b/infer/src/base/Utils.mli index 04a3cec11..6f3140199 100644 --- a/infer/src/base/Utils.mli +++ b/infer/src/base/Utils.mli @@ -11,6 +11,7 @@ (** General utility functions *) module Bool = Core.Std.Bool +module Filename = Core.Std.Filename module Int = Core.Std.Int module String = Core.Std.String diff --git a/infer/src/harness/inhabit.ml b/infer/src/harness/inhabit.ml index a09c6a82a..c96a425b2 100644 --- a/infer/src/harness/inhabit.ml +++ b/infer/src/harness/inhabit.ml @@ -204,10 +204,10 @@ let inhabit_call tenv (procname, receiver) cfg env = (** create a dummy file for the harness and associate them in the exe_env *) let create_dummy_harness_filename harness_name = let dummy_file_dir = - Filename.get_temp_dir_name () in + Filename.temp_dir_name in let file_str = Procname.java_get_class_name - harness_name ^ "_" ^Procname.java_get_method harness_name ^ ".java" in + harness_name ^ "_" ^ Procname.java_get_method harness_name ^ ".java" in Filename.concat dummy_file_dir file_str (** write the SIL for the harness to a file *) diff --git a/infer/src/integration/CaptureCompilationDatabase.ml b/infer/src/integration/CaptureCompilationDatabase.ml index 15c424066..b5c4ba8e3 100644 --- a/infer/src/integration/CaptureCompilationDatabase.ml +++ b/infer/src/integration/CaptureCompilationDatabase.ml @@ -138,7 +138,7 @@ let get_compilation_database_files_xcodebuild () = let cmd_and_args = IList.rev Config.rest in let temp_dir = Config.results_dir // "clang" in create_dir temp_dir; - let tmp_file = Filename.temp_file ~temp_dir:temp_dir "cdb" ".json" in + let tmp_file = Filename.temp_file ~in_dir:temp_dir "cdb" ".json" in let xcodebuild_cmd, xcodebuild_args = match cmd_and_args with | [] -> failwith("Build command cannot be empty") diff --git a/infer/src/integration/ClangQuotes.re b/infer/src/integration/ClangQuotes.re index 0befd29c9..01f2807fb 100644 --- a/infer/src/integration/ClangQuotes.re +++ b/infer/src/integration/ClangQuotes.re @@ -33,7 +33,7 @@ let quote style => let mk_arg_file prefix style args => { let temp_dir = Config.results_dir /\/ "clang"; create_dir temp_dir; - let file = Filename.temp_file temp_dir::temp_dir prefix ".txt"; + let file = Filename.temp_file in_dir::temp_dir prefix ".txt"; let write_args outc => output_string outc (IList.map (quote style) args |> String.concat sep::" "); with_file file f::write_args |> ignore;