package carton

  1. Overview
  2. Docs
Implementation of PACKv2 file in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

carton-carton-v0.1.0.tbz
sha256=2fcf72f1039da2aea64c6da3f67f7110f1b2fa27b0a5c433f2a243fd9a4e02e8
sha512=d60b0cb52eea1362cfb6457fad3d0a544d8ae1d69568255d1a685343973222695e8360d46833780dac69c196b05f03260fe2ea3d270e5021cf596d47a00f4c6d

doc/carton.thin/Thin/Make/index.html

Module Thin.MakeSource

Parameters

module IO : Carton.IO with type 'a t = 'a Scheduler.s
module Uid : Carton.UID

Signature

Sourcetype ('t, 'path, 'fd, 'error) fs = {
  1. create : 't -> 'path -> ('fd, 'error) result IO.t;
  2. append : 't -> 'fd -> string -> unit IO.t;
  3. map : 't -> 'fd -> pos:int64 -> int -> Bigstringaf.t IO.t;
  4. close : 't -> 'fd -> (unit, 'error) result IO.t;
}

A record to manipulate a file-system.

create is like Unix.openfile. It can open a pre-existing 'path or create a new one. It returns a representation of it which can be manipulated. append is like Unix.write. It appends the given payload into the opened fd. It shifts the offset of the opened file by the length of the given payload. map is like Unix.map_file. It loads a part of the given 'fd into a Bigstringaf.t payload. It always called with valid pos and len arguments.

Sourceval verify : ?threads:int -> digest:Uid.t Carton.Dec.digest -> 't -> 'path -> ('t, 'path, 'fd, [> `Msg of string ] as 'error) fs -> (unit -> (string * int * int) option IO.t) -> (int * Uid.t list * (int64 * optint) list * Uid.t Carton.Dec.Idx.entry list * int64 * Uid.t, 'error) result IO.t

verify ~digest filename fs stream does the first pass to analyze a PACK file. While it analyzes the PACK file, it saves it into filename with the fs's append syscall. Then, it returns how many objects has the stream, the list of required external objects and the size of the stream.

If the list is empty, the given stream (saved into filename) is a canonic PACK file. It does not require any external objects to extract any of its objects.

Otherwise, you probably should call canonicalize to regenerate the PACK file.

Sourcetype nonrec light_load = (Uid.t, Scheduler.t) light_load
Sourcetype nonrec heavy_load = (Uid.t, Scheduler.t) heavy_load
Sourceval canonicalize : light_load:light_load -> heavy_load:heavy_load -> src:'path -> dst:'path -> 't -> ('t, 'path, 'fd, [> `Msg of string ] as 'error) fs -> int -> Uid.t list -> int64 -> (int64 * int64 * Uid.t * Uid.t Carton.Dec.Idx.entry list, 'error) result IO.t

canonicalize ~light_load ~heavy_load ~transmit filename fs n requireds weight generates a new PACK file with required objects requireds. It puts on the front these objects available with light_load and heavy_load.

Then, it transmits all others objects of the old PACK file to the new one with transmit. It must know how many objects has the old PACK file and size of it.

It returns the size of the new PACK file generated located to filename.

OCaml

Innovation. Community. Security.