From 998960930f585ca807d2fd3e45c77124c5b82aa8 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Sat, 31 Aug 2019 02:30:45 -0700 Subject: [PATCH] [deadcode] multilinks Summary: deadcode Reviewed By: skcho Differential Revision: D17133578 fbshipit-source-id: 9cb6edd43 --- infer/src/base/Multilinks.ml | 66 ----------------------------------- infer/src/base/Multilinks.mli | 36 ------------------- 2 files changed, 102 deletions(-) delete mode 100644 infer/src/base/Multilinks.ml delete mode 100644 infer/src/base/Multilinks.mli diff --git a/infer/src/base/Multilinks.ml b/infer/src/base/Multilinks.ml deleted file mode 100644 index d51bd82c0..000000000 --- a/infer/src/base/Multilinks.ml +++ /dev/null @@ -1,66 +0,0 @@ -(* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - *) - -open! IStd -open PolyVariantEqual -module F = Format -module L = Logging - -let multilink_file_name = "multilink.txt" - -type t = string String.Table.t - -let add multilinks fname = String.Table.set multilinks ~key:(Filename.basename fname) ~data:fname - -let create () : t = String.Table.create ~size:1 () - -(* Cache of multilinks files read from disk *) -let multilink_files_cache = String.Table.create ~size:1 () - -let reset_cache () = String.Table.clear multilink_files_cache - -let read ~dir : t option = - let multilink_fname = Filename.concat dir multilink_file_name in - match Utils.read_file multilink_fname with - | Error _ -> - None - | Ok lines -> - let links = create () in - List.iter - ~f:(fun line -> String.Table.set links ~key:(Filename.basename line) ~data:line) - lines ; - String.Table.set multilink_files_cache ~key:dir ~data:links ; - Some links - - -(* Write a multilink file in the given directory *) -let write multilinks ~dir = - let fname = Filename.concat dir multilink_file_name in - let outc = Out_channel.create fname in - String.Table.iteri - ~f:(fun ~key:_ ~data:src -> Out_channel.output_string outc (src ^ "\n")) - multilinks ; - Out_channel.close outc - - -let lookup ~dir = - try Some (String.Table.find_exn multilink_files_cache dir) - with Not_found_s _ | Caml.Not_found -> read ~dir - - -let resolve fname = - let fname_s = DB.filename_to_string fname in - if Sys.file_exists fname_s = `Yes then fname - else - let base = Filename.basename fname_s in - let dir = Filename.dirname fname_s in - match lookup ~dir with - | None -> - fname - | Some links -> ( - try DB.filename_from_string (String.Table.find_exn links base) - with Not_found_s _ | Caml.Not_found -> fname ) diff --git a/infer/src/base/Multilinks.mli b/infer/src/base/Multilinks.mli deleted file mode 100644 index bafadd37d..000000000 --- a/infer/src/base/Multilinks.mli +++ /dev/null @@ -1,36 +0,0 @@ -(* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - *) - -open! IStd -module F = Format -module L = Logging - -(** In-memory representation of multilink files. *) -type t - -val add : t -> string -> unit -(** Add a link. *) - -val create : unit -> t -(** Create a new multilink. *) - -val multilink_file_name : string -(** Name of the multilink file. - A multilink file is recognized by its file name. *) - -val read : dir:string -> t option -(** Read a multilink file from disk. *) - -val resolve : DB.filename -> DB.filename -(** Resolve a filename following multilinks. - The cache is updated if a new multilinks file is read. *) - -val reset_cache : unit -> unit -(** Reset the cache of multilink files *) - -val write : t -> dir:string -> unit -(** Write a multilink file in the given directory *)