Module Std.Bundle

Program Bundle.

Bundle is a collection of data associated with a program. To access the bundle, use the main_bundle function, e.g.,

open Bap_bundle.Std

let bundle = main_bundle ()
type t = bundle
val of_uri : Uri.t -> t

creates new bundle or opens existing

val manifest : t -> manifest

manifest bundle extracts program manifest from the bundle

val get_file : ?name:string -> t -> Uri.t -> Uri.t option

get_file ?name bundle uri extracts a file.

Extracts a file specified by a uri from a bundle and returns a uri pointing to the extracted file, if was found. The optional parameter name allows to specify the desired filename for the extraction.

val get_data : t -> string -> string option

get_data bundle path extracts data specified by a path as a string.

val list : t -> string list

list bundle returns a list of paths, that are accessible in the bundle.

val update_manifest : t -> f:(manifest -> manifest) -> unit

update_manifest bundle ~f update program manifest with function f.

val insert_files : t -> (string option * Uri.t) list -> unit

insert_files bundle spec bundle files.

The spec is a list of pairs, where the first constituent of a pair is a desired path of the file in the bundle, and the second constituent is the uri of the file, that should be inserted. If the first element of the pair is None, then the file will be inserted under the same path, as it was in the file system.

val insert_file : ?name:string -> t -> Uri.t -> unit

insert_file ?name bundle uri insert a file specified by the uri. If name is specified, then the file will be stored under the specified name in the bundle.

val insert_data : t -> name:string -> data:string -> unit

insert_data bundle ~name ~data insert data at path name.

val update : t -> f: (string -> [ `Drop | `Copy | `Proc of string -> unit | `Map of string -> string ]) -> unit

update bundle ~f:action add, remove or update data in the bundle.

This is a swiss-knife function, that can do arbitrary bundle modification. See get_file, get_data, insert_files, insert_file and insert_data for an easier to use interface.

The action function is called on each path, and must return one of the following:

  • `Drop - to remove the path from the bundle;
  • `Copy - to keep it untouched;
  • `Proc f - extract it, process the file with a function f, and put back, where function f accepts a temporary name of extracted file;
  • `Map f - map the contents of the file with function f.

Warning. Modification of a bundle, associated with an installed plugin or application will lead to an undefined behavior. The function is intended for building a new bundle. Once it is created it may be sealed and made readonly.

module Builder : sig ... end

Incremental bundle builder.