Eio_fs_mem.CrunchSourceDirectory trees embedded in an executable, loaded as load loads a copy.
Compile-time file embedding for the in-memory filesystem, in the style of ocaml-crunch. The eio-fs-crunch binary serialises a directory tree into an OCaml module of entry values; at runtime the generated module's load () rebuilds the tree in a new in-memory filesystem. A copy of a directory made at run time, with no binary, is Eio_fs_mem.load.
With -o assets.ml the binary writes the module and its interface, assets.mli. This dune rule regenerates them when the static directory changes:
(rule
(targets assets.ml assets.mli)
(deps
(source_tree static))
(action
(run %{bin:eio-fs-crunch} -o assets.ml static)))The type for nodes of an embedded file tree. Paths are absolute within the image and use "/" as separator. A tree is a list of them, every directory before its children: eio-fs-crunch records its directory as Dir { path = "/"; _ }, then the entries below it in depth-first order, names sorted, a symbolic link without following it.
find path entries is Some contents for the first File at path in entries, and None if there is none. path is absolute within the image, as eio-fs-crunch records it, and compared as a string; a symbolic link is not followed. A program that embeds fixtures reads them with it and needs no filesystem.
val load :
?os:[< `Linux | `Macos | `Windows ] ->
?clock:_ Eio.Time.clock ->
entry list ->
[ `Close | Eio.Fs.dir_ty ] Eio.Path.tload ~os ~clock entries is the root of a new in-memory filesystem that answers as os (defaults to `Linux) does, holding entries, with their permissions and symbolic links. Its times are read from clock, as Eio_fs_mem.v reads them. A Dir creates its missing ancestors; a File or Symlink needs its parent directory to exist already, as the root or from an earlier entry.
pp_ml formats the .ml file of a standalone OCaml module embedding the entries. The generated module exposes entries : Eio_fs_mem.Crunch.entry list and load ?os ?clock (), which is load of entries with the same optional arguments.