diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-25 22:57:24 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-10-21 19:08:40 -0400 |
| commit | b82afb4a7d479024d0a5ea206cabf85c36bd9af1 (patch) | |
| tree | 2254a6ec5990cff354338986eebf52012c0782f1 /dlang/src/ocda/load.d | |
| parent | test: incorrect fixture property line indentation (diff) | |
a third input form: abstraction from a pod archive
A pod built with --pod2 carries the abstraction inside it, at
media/abstraction/<uid>.<lang>.ssp. So ocda.load gains .sisupod and
.zip, and because the dispatch is in one place a writer over the library
gained a third input form without being touched.
Over the reference collection a .sisupod gives the same model as the
.ssp beside it: all document (& prog-language) outputs, byte identical
dumps. And the text writer, unchanged, renders a document from its
.sisupod byte identically to spine --text, 36 of 36.
Two small readers, neither of them a library: ocda.zstd declares the
four libzstd entry points needed to unwrap a frame, as ocda.sqlite
declares sqlite3; ocda.zip reads a central directory and one stored
entry. Deflate is refused rather than mishandled, since spine writes
stored entries and a library that says it read what it skipped is worse
than one that says it cannot. A frame that declares an expansion over
512 MiB is refused before anything is allocated: a reader of an artefact
it did not make declines to be told how much memory to take.
The Gleam library reads the zip and not the frame. The only zstd on the
BEAM is a NIF that clones zstd from github in its own build, so it
cannot be built sandboxed without patching it. A .zip pod is read in
both languages, a .sisupod in D only, and the Gleam refusal says why and
says "zstd -d" rather than claiming the file is malformed. It is a
packaging limit, not anything about the format, and the only place the
two libraries differ in what they accept.
A pod without an abstraction is refused with a message naming the flag
that puts one in, because that is a fact about the pod.
(assisted by Claude-Code)
Diffstat (limited to 'dlang/src/ocda/load.d')
| -rw-r--r-- | dlang/src/ocda/load.d | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/dlang/src/ocda/load.d b/dlang/src/ocda/load.d index 0f630bc..89c8dcc 100644 --- a/dlang/src/ocda/load.d +++ b/dlang/src/ocda/load.d @@ -17,16 +17,24 @@ import std.algorithm : endsWith; import ocda.model; import ocda.load_ssp; import ocda.load_db; +import ocda.load_pod; enum Source { ssp, // .ssp, the abstraction as text ocda_db, // .ocda.db, the abstraction as sqlite + pod, // .sisupod or .zip, an archive carrying a .ssp unknown, } Source sourceOf(string path) { if (path.endsWith(".ocda.db")) { return Source.ocda_db; } if (path.endsWith(".ssp")) { return Source.ssp; } + /+ ↓ .sisupod is the archive spine writes now; .zip is what it wrote + before, and every pod already published carries that name, so both + are read. What is inside decides how it is opened, not the name. + +/ + if (path.endsWith(".sisupod")) { return Source.pod; } + if (path.endsWith(".zip")) { return Source.pod; } if (path.endsWith(".db")) { return Source.ocda_db; } return Source.unknown; } @@ -35,6 +43,7 @@ string sourceName(Source s) { final switch (s) { case Source.ssp: return ".ssp (the abstraction as text)"; case Source.ocda_db: return ".ocda.db (the abstraction as sqlite)"; + case Source.pod: return "a pod archive carrying a .ssp"; case Source.unknown: return "not an abstraction this library reads"; } } @@ -44,15 +53,17 @@ class OcdaLoadError : Exception { } /+ ↓ load whatever the path is into the model. - lang applies only to a .ocda.db, which holds every language of its - document; a .ssp is one language and the argument is ignored. + lang names which language to take from a .ocda.db, which holds + every language of its document, and from a pod, which may carry more + than one .ssp. A .ssp is one language by construction and ignores it. +/ OcdaDocument load(string path, string lang = "", bool any_version = false) { final switch (sourceOf(path)) { case Source.ssp: return parseSspFile(path); case Source.ocda_db: return loadDbFile(path, lang, any_version); + case Source.pod: return loadPodFile(path, lang); case Source.unknown: throw new OcdaLoadError(path ~ ": " ~ sourceName(Source.unknown) - ~ " (expected .ssp or .ocda.db)"); + ~ " (expected .ssp, .ocda.db, .sisupod or .zip)"); } } |
