Core.Std.Filename

Reviewed By: cristianoc

Differential Revision: D4232427

fbshipit-source-id: 01df454
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 782e9d69f6
commit 7d57469d2f

@ -56,7 +56,7 @@ let set_log_file_identifier (current_exe : CLOpt.exe) string_opt =
let file = let file =
(* the command-line option takes precedence if specified *) (* the command-line option takes precedence if specified *)
if name <> "" then name 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 chan = Pervasives.open_out file in
let fmt = F.formatter_of_out_channel chan in let fmt = F.formatter_of_out_channel chan in
(fmt, chan, file) (fmt, chan, file)

@ -86,7 +86,7 @@ let create_serializer (key : key) : 'a serializer =
(* support nonblocking reads and writes in parallel: *) (* support nonblocking reads and writes in parallel: *)
(* write to a tmp file and use rename which is atomic *) (* write to a tmp file and use rename which is atomic *)
let fname_tmp = Filename.temp_file 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 let outc = open_out_bin fname_tmp in
Marshal.to_channel outc (key, version, value) []; Marshal.to_channel outc (key, version, value) [];
close_out outc; close_out outc;

@ -132,7 +132,7 @@ let of_header header_file =
let abs_path = to_abs_path header_file in let abs_path = to_abs_path header_file in
let source_exts = ["c"; "cc"; "cpp"; "cxx"; "m"; "mm"] in let source_exts = ["c"; "cc"; "cpp"; "cxx"; "m"; "mm"] in
let header_exts = ["h"; "hh"; "hpp"; "hxx"] 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 let file_opt = match ext_opt with
| Some ext when IList.mem String.equal ext header_exts -> ( | Some ext when IList.mem String.equal ext header_exts -> (
let possible_files = IList.map (fun ext -> file_no_ext ^ "." ^ ext) source_exts in let possible_files = IList.map (fun ext -> file_no_ext ^ "." ^ ext) source_exts in

@ -11,6 +11,7 @@
(** General utility functions and definition with global scope *) (** General utility functions and definition with global scope *)
module Bool = Core.Std.Bool module Bool = Core.Std.Bool
module Filename = Core.Std.Filename
module Int = Core.Std.Int module Int = Core.Std.Int
module String = Core.Std.String module String = Core.Std.String
@ -572,7 +573,7 @@ let realpath_cache = Hashtbl.create 1023
let realpath path = let realpath path =
match Hashtbl.find realpath_cache path with match Hashtbl.find realpath_cache path with
| exception Not_found -> ( | exception Not_found -> (
match Core.Std.Filename.realpath path with match Filename.realpath path with
| realpath -> | realpath ->
Hashtbl.add realpath_cache path (Ok realpath); Hashtbl.add realpath_cache path (Ok realpath);
realpath realpath
@ -582,7 +583,6 @@ let realpath path =
(* cache failures as well *) (* cache failures as well *)
Hashtbl.add realpath_cache path (Error (code, f, arg)); Hashtbl.add realpath_cache path (Error (code, f, arg));
raise (Unix.Unix_error (code, f, arg)) raise (Unix.Unix_error (code, f, arg))
) )
| Ok path -> path | Ok path -> path
| Error (code, f, arg) -> raise (Unix.Unix_error (code, f, arg)) | Error (code, f, arg) -> raise (Unix.Unix_error (code, f, arg))

@ -11,6 +11,7 @@
(** General utility functions *) (** General utility functions *)
module Bool = Core.Std.Bool module Bool = Core.Std.Bool
module Filename = Core.Std.Filename
module Int = Core.Std.Int module Int = Core.Std.Int
module String = Core.Std.String module String = Core.Std.String

@ -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 *) (** create a dummy file for the harness and associate them in the exe_env *)
let create_dummy_harness_filename harness_name = let create_dummy_harness_filename harness_name =
let dummy_file_dir = let dummy_file_dir =
Filename.get_temp_dir_name () in Filename.temp_dir_name in
let file_str = let file_str =
Procname.java_get_class_name 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 Filename.concat dummy_file_dir file_str
(** write the SIL for the harness to a file *) (** write the SIL for the harness to a file *)

@ -138,7 +138,7 @@ let get_compilation_database_files_xcodebuild () =
let cmd_and_args = IList.rev Config.rest in let cmd_and_args = IList.rev Config.rest in
let temp_dir = Config.results_dir // "clang" in let temp_dir = Config.results_dir // "clang" in
create_dir temp_dir; 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 = let xcodebuild_cmd, xcodebuild_args =
match cmd_and_args with match cmd_and_args with
| [] -> failwith("Build command cannot be empty") | [] -> failwith("Build command cannot be empty")

@ -33,7 +33,7 @@ let quote style =>
let mk_arg_file prefix style args => { let mk_arg_file prefix style args => {
let temp_dir = Config.results_dir /\/ "clang"; let temp_dir = Config.results_dir /\/ "clang";
create_dir temp_dir; 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 => let write_args outc =>
output_string outc (IList.map (quote style) args |> String.concat sep::" "); output_string outc (IList.map (quote style) args |> String.concat sep::" ");
with_file file f::write_args |> ignore; with_file file f::write_args |> ignore;

Loading…
Cancel
Save