package SZXX

  1. Overview
  2. Docs

Module SZXX.ZipSource

Sourcetype methd =
  1. | Stored
  2. | Deflated
Sourceval sexp_of_methd : methd -> Sexplib0.Sexp.t
Sourcetype version =
  1. | Zip_2_0
  2. | Zip_4_5
Sourceval sexp_of_version : version -> Sexplib0.Sexp.t
Sourcetype descriptor = {
  1. crc : Core_kernel.Int32.t;
  2. compressed_size : Core_kernel.Int64.t;
  3. uncompressed_size : Core_kernel.Int64.t;
}
Sourceval sexp_of_descriptor : descriptor -> Sexplib0.Sexp.t
Sourcetype extra_field = {
  1. id : int;
  2. size : int;
  3. data : string;
}
Sourceval sexp_of_extra_field : extra_field -> Sexplib0.Sexp.t
Sourcetype entry = {
  1. version_needed : version;
  2. flags : int;
  3. trailing_descriptor_present : bool;
  4. methd : methd;
  5. descriptor : descriptor;
  6. filename : string;
  7. extra_fields : extra_field list;
}
Sourceval sexp_of_entry : entry -> Sexplib0.Sexp.t
Sourcemodule Action : sig ... end
Sourcemodule Data : sig ... end
Sourcetype 'a slice = {
  1. buf : 'a;
  2. pos : int;
  3. len : int;
}
Sourcetype feed =
  1. | String of unit -> string option Lwt.t
  2. | Bigstring of unit -> Core_kernel.Bigstring.t slice option Lwt.t
Sourceval stream_files : feed:feed -> (entry -> 'a Action.t) -> (entry * 'a Data.t) Lwt_stream.t * unit Lwt.t

Stream files.

SZXX.Zip.stream_files ~feed callback

feed: Produces data for the parser. This data can be simple strings or bigstrings. Return None to indicate EOF.

callback: function called on every file found within the ZIP archive. You must choose an Action for SZXX to perform over each file encountered within the ZIP archive.

Return Action.Skip to skip over the compressed bytes of this file without attempting to uncompress them. Return Action.String to collect the whole uncompressed file into a single string. Return Action.Fold_string to fold this file into a final state, in string chunks of ~1k-5k. Return Action.Fold_bigstring to fold this file into a final state, in bigstring chunks of ~1k-5k. Return Action.Parse to apply an Angstrom.t parser to the file while it is being uncompressed without having to fully uncompress it first.

This function returns stream * success_promise stream contains all files in the same order they were found in the archive. success_promise is a promise that resolves once the entire zip archive has been processed.

Important: bind to/await success_promise in order to capture any errors encountered while processing the file.

See README.md for examples on how to use it.