From 8759017f7c6d118a8ee5e5c21130a9cfbb150621 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 2 Apr 2016 06:02:08 -0700 Subject: [PATCH] Store proc attributes inside bucket directories. Reviewed By: jberdine Differential Revision: D3131009 fb-gh-sync-id: de5fec3 fbshipit-source-id: de5fec3 --- infer/src/IR/attributesTable.ml | 15 +++++++++++++-- infer/src/backend/DB.ml | 5 +++++ infer/src/backend/DB.mli | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/infer/src/IR/attributesTable.ml b/infer/src/IR/attributesTable.ml index 408b409a0..167090a91 100644 --- a/infer/src/IR/attributesTable.ml +++ b/infer/src/IR/attributesTable.ml @@ -21,8 +21,19 @@ let attributes_filename pname = (** path to the .attr file for the given procedure in the current results directory *) let res_dir_attr_filename pname = - DB.Results_dir.path_to_filename - DB.Results_dir.Abs_root [Config.attributes_dir_name; attributes_filename pname] + let attr_fname = attributes_filename pname in + let bucket_dir = + let base = Filename.chop_extension attr_fname in + let len = String.length base in + if len < 2 + then Filename.current_dir_name + else String.sub base (len - 2) 2 in + let filename = + DB.Results_dir.path_to_filename + DB.Results_dir.Abs_root + [Config.attributes_dir_name; bucket_dir; attr_fname] in + DB.filename_create_dir filename; + filename let store_attributes proc_attributes = let proc_name = proc_attributes.ProcAttributes.proc_name in diff --git a/infer/src/backend/DB.ml b/infer/src/backend/DB.ml index 2aa1842d1..b450280e3 100644 --- a/infer/src/backend/DB.ml +++ b/infer/src/backend/DB.ml @@ -202,6 +202,11 @@ let create_dir dir = (L.err "@.ERROR: cannot create directory %s@." dir; assert false)) +let filename_create_dir fname = + let dirname = Filename.dirname fname in + if not (Sys.file_exists dirname) + then create_dir dirname + let read_whole_file fd = let stats = Unix.fstat fd in let size = stats.Unix.st_size in diff --git a/infer/src/backend/DB.mli b/infer/src/backend/DB.mli index 35b0ad81a..162b65b66 100644 --- a/infer/src/backend/DB.mli +++ b/infer/src/backend/DB.mli @@ -134,6 +134,9 @@ val source_file_in_resdir : source_file -> filename (** directory where the results of the capture phase are stored *) val captured_dir : unit -> filename +(** create the directory containing the file bane *) +val filename_create_dir : filename -> unit + (** Find the source directories in the current results dir *) val find_source_dirs : unit -> source_dir list