From 104341a4625fc9dea240f9d710004f75c7c0b071 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Wed, 24 Jan 2024 13:41:52 +0100 Subject: [PATCH] bring back support for absolute paths in find_file This is a bit messy now because we want to track which class path we used to resolve a file, but in the case of absolute paths we didn't really use a class path. It makes sense to introduce an absolute class path like here, but we already use the empty string as the cwd class path too. --- src/core/classPaths.ml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/classPaths.ml b/src/core/classPaths.ml index 1fbab6f3efc..f7710aa1fad 100644 --- a/src/core/classPaths.ml +++ b/src/core/classPaths.ml @@ -11,6 +11,9 @@ let create_resolved_file file class_path = { class_path; } +(* We need to clean-up absolute ("") vs. cwd ("."). *) +let absolute_class_path = new directory_class_path "" User + class class_paths = object(self) val mutable l = [] val file_lookup_cache = new Lookup.hashtbl_lookup; @@ -122,7 +125,16 @@ class class_paths = object(self) None | Some f -> Some f - with Not_found -> + with + | Not_found when Path.is_absolute_path f -> + let r = if Sys.file_exists f then + Some (create_resolved_file f absolute_class_path) + else + None + in + file_lookup_cache#add f r; + r + | Not_found -> let rec loop = function | [] -> None