File tree Expand file tree Collapse file tree 5 files changed +28
-14
lines changed Expand file tree Collapse file tree 5 files changed +28
-14
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ let _ = Hashtbl.add directive_table "cd" (Directive_string dir_cd)
7373
7474(* Load in-core a .cmxs file *)
7575
76+ let loaded_files = ref Stdlib.String.Set. empty
77+
7678let load_file ppf name0 =
7779 let name =
7880 try Some (Load_path. find name0)
@@ -90,7 +92,7 @@ let load_file ppf name0 =
9092 else
9193 name,false
9294 in
93- let success =
95+ let loaded =
9496 (* The Dynlink interface does not allow us to distinguish between
9597 a Dynlink.Error exceptions raised in the loaded modules
9698 or a genuine error during dynlink... *)
@@ -105,8 +107,10 @@ let load_file ppf name0 =
105107 false
106108 in
107109 if tmp then (try Sys. remove fn with Sys_error _ -> () );
108- success
110+ if loaded then loaded_files := Stdlib.String.Set. add name ! loaded_files;
111+ loaded
109112
113+ let loaded_files () = ! loaded_files
110114
111115let dir_load ppf name = ignore (load_file ppf name)
112116
Original file line number Diff line number Diff line change @@ -31,3 +31,7 @@ type 'a printer_type_old = 'a -> unit
3131
3232(* For topmain.ml. Maybe shouldn't be there *)
3333val load_file : formatter -> string -> bool
34+
35+ val loaded_files : unit -> Set .Make (String ).t
36+ (* * [loaded_files ()] is the set of object and archive files that were
37+ loaded so far. *)
Original file line number Diff line number Diff line change @@ -160,17 +160,18 @@ let load_compunit ic filename ppf compunit =
160160 raise Load_failed
161161 end
162162
163- let rec load_file recursive ppf name =
164- let filename =
165- try Some (Load_path. find name) with Not_found -> None
166- in
167- match filename with
168- | None -> fprintf ppf " Cannot find file %s.@." name; false
169- | Some filename ->
170- let ic = open_in_bin filename in
171- Misc. try_finally
172- ~always: (fun () -> close_in ic)
173- (fun () -> really_load_file recursive ppf name filename ic)
163+ let loaded_files = ref Stdlib.String.Set. empty
164+
165+ let rec load_file recursive ppf name = match Load_path. find name with
166+ | exception Not_found -> fprintf ppf " Cannot find file %s.@." name; false
167+ | file ->
168+ let ic = open_in_bin file in
169+ let loaded =
170+ Misc. try_finally ~always: (fun () -> close_in ic)
171+ (fun () -> really_load_file recursive ppf name file ic)
172+ in
173+ (if loaded then loaded_files := Stdlib.String.Set. add file ! loaded_files);
174+ loaded
174175
175176and really_load_file recursive ppf name filename ic =
176177 let buffer = really_input_string ic (String. length Config. cmo_magic_number) in
@@ -236,6 +237,7 @@ let _ = add_directive "load_rec"
236237 }
237238
238239let load_file = load_file false
240+ let loaded_files () = ! loaded_files
239241
240242(* Load commands from a file *)
241243
Original file line number Diff line number Diff line change @@ -34,3 +34,7 @@ type 'a printer_type_old = 'a -> unit
3434
3535(* For topmain.ml. Maybe shouldn't be there *)
3636val load_file : formatter -> string -> bool
37+
38+ val loaded_files : unit -> Set .Make (String ).t
39+ (* * [loaded_files ()] is the set of object and archive files that were
40+ loaded so far. *)
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ module Stdlib : sig
166166
167167 module String : sig
168168 include module type of String
169- module Set : Set .S with type elt = string
169+ module Set : Set .S with type elt = string and type t = Set. Make ( String ).t
170170 module Map : Map .S with type key = string
171171 module Tbl : Hashtbl .S with type key = string
172172
You can’t perform that action at this time.
0 commit comments