...
 
Commits (2)
......@@ -464,6 +464,10 @@ let list_packages ?(tab = 20) ?(descr = false) ch =
packages_sorted
;;
let list_packages' ?prefix () =
lazy_init();
Fl_package_base.list_packages ?prefix ()
type rectype =
| Record_core
......
......@@ -232,6 +232,12 @@ val list_packages : ?tab:int -> ?descr:bool -> out_channel -> unit
* @param descr Whether package descriptions are printed. Default: false
*)
val list_packages' : ?prefix:string -> unit -> string list
(** Returns the (unsorted) list of all packages.
*
* @param prefix Limit to the packages that starts with it. Default: unlimited
*)
(** Managing dynamically loaded packages *)
(** This is a registry of packages that are available in-core. This is both
......
......@@ -531,11 +531,17 @@ let package_conflict_report ?identify_dir () =
| Some f -> package_conflict_report_1 f ()
;;
let load_base() =
let check_prefix ?prefix f =
match prefix with
| None -> true
| Some prefix ->
let len = String.length prefix in
String.length f >= len && String.sub f 0 len = prefix
let load_base ?prefix () =
(* Ensures that the cache is completely filled with every package
* of the system
*)
* of the system that match prefix
*)
let list_directory d =
try
Array.to_list(Sys.readdir d)
......@@ -570,9 +576,11 @@ let load_base() =
match path with
[] -> ()
| dir :: path' ->
let files = list_directory dir in
let files = list_directory dir in
List.iter
(fun f ->
(fun f ->
if check_prefix ?prefix f
then
(* If f/META exists: Add package f *)
let package_dir = Filename.concat dir f in
let meta_file_1 = Filename.concat package_dir "META" in
......@@ -596,14 +604,16 @@ let load_base() =
;;
let list_packages() =
load_base();
let list_packages ?prefix () =
load_base ?prefix ();
let l = ref [] in
Fl_metastore.iter_up
(fun m ->
l := m.package_name :: !l)
if check_prefix ?prefix m.package_name then
l := m.package_name :: !l
)
store;
!l
......
......@@ -118,16 +118,20 @@ val module_conflict_report : ?identify_dir:(string -> 'a) -> string list -> unit
* @param identify_dir See [package_conflict_report].
*)
val load_base : unit -> unit
val load_base : ?prefix:string -> unit -> unit
(** Ensures that the complete package graph is loaded into memory.
* This is a time-consuming operation. Warnings may be printed to
* stderr.
*
* @param prefix Limit to the packages that starts with it. Default: unlimited
*)
val list_packages : unit -> string list
val list_packages : ?prefix:string -> unit -> string list
(** Ensures that the complete package graph is loaded into memory
* (like [load_base]), and returns the (unsorted) list of all
* packages.
*
* @param prefix Limit to the packages that starts with it. Default: unlimited
*)
val package_users : preds:string list -> string list -> string list
......