[DB] Alawys use DB.source_file_to_abs_path to do actual filesystem operations

Summary:
Using DB.source_file_to_string may return relative path which may or may not be relative to current location.
I went through all calls to `DB.source_file_to_string` and fixed ones that used that output to open files

Reviewed By: jeremydubreil

Differential Revision: D4205407

fbshipit-source-id: b285b7e
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 548918e524
commit b2cef3e0b2

@ -85,7 +85,7 @@ module FileContainsStringMatcher = struct
DB.SourceFileMap.find source_file !source_map
with Not_found ->
try
let file_in = open_in (DB.source_file_to_string source_file) in
let file_in = open_in (DB.source_file_to_abs_path source_file) in
let pattern_found = file_contains regexp file_in in
close_in file_in;
source_map := DB.SourceFileMap.add source_file pattern_found !source_map;

@ -48,7 +48,7 @@ struct
Some (Hashtbl.find hash fname)
with Not_found ->
try
let lines_arr = read_file (DB.source_file_to_string fname) in
let lines_arr = read_file (DB.source_file_to_abs_path fname) in
Hashtbl.add hash fname lines_arr;
Some lines_arr
with exn when SymOp.exn_not_failure exn -> None

@ -217,7 +217,7 @@ let create_dummy_harness_file harness_name =
(* TODO (t3040429): fill this file up with Java-like code that matches the SIL *)
let write_harness_to_file harness_instrs harness_file =
let harness_file =
let harness_file_name = DB.source_file_to_string harness_file in
let harness_file_name = DB.source_file_to_abs_path harness_file in
create_outfile harness_file_name in
let pp_harness fmt = IList.iter (fun instr ->
Format.fprintf fmt "%a\n" (Sil.pp_instr pe_text) instr) harness_instrs in

@ -103,7 +103,7 @@ type file_entry =
(* Open the source file and search for the package declaration.
Only the case where the package is declared in a single line is supported *)
let read_package_declaration source_file =
let path = DB.source_file_to_string source_file in
let path = DB.source_file_to_abs_path source_file in
let file_in = open_in path in
let remove_trailing_semicolon =
Str.replace_first (Str.regexp ";") "" in

Loading…
Cancel
Save