nqdpack(3)
NAME
nqdpack, nqdunpack
— a capsule in one file, and back
LIBRARY
libnqd, -lnqd -lnoqtis
SYNOPSIS
#include
<nqd.h>
int
nqdpack(const
char *dir, int
files, const char
*file);
int
nqdunpack(const char *file,
const char *dir, int rm,
char *why, size_t cap);
DESCRIPTION
nqdpack()
writes the sealed capsule dir to the new
file as a bundle
(‘noqtis-bundle-1,
noqtis-capsule(5)’):
its noqtis.json, noqtis.sig,
noqtis.ers when there is one, and every file its
manifest lists (files 1), or
of those only its data record noqtis.data.json
(files 0), in the byte order
of their paths. The same folder gives the same bytes.
file must not exist; on any error it is removed again.
Nothing is checked: check the capsule with
nqchk(3) first.
nqdunpack()
reads the bundle file into the new folder
dir, which it makes. The reader is strict, and refuses
the bundle whole, removing everything it wrote and
dir, for: a file that does not start with the format's
line; a path that is not one a capsule holds (empty, absolute, with
‘.’ or
‘..’, a backslash, a colon, so no
drive letter, a control character, invalid UTF-8, a NUL) or that is over 64
folders deep, and on Windows a name the system takes for a device
(‘CON, ‘’) or one ending in a dot or
space; paths out of order or given twice; no
noqtis.json or noqtis.sig; a
bundle cut short or with bytes after its end; a path over 4096 bytes, more
than 2,000,003 entries, a file over 2^53 - 1 bytes, a seal over 1 MiB or a
manifest over 512 MiB. Every file is created new, never over one that is
there or through a link, and every folder is made by
NUL,
‘’COM1,
...’nqdunpack() inside dir, so no
path leaves it; two paths that differ only in case on a file system that
ignores case are refused. Check dir afterwards with
nqchk(3); when the bundle
carries only the data record, check that alone
(nqchkx(3) with
only).
With rm 1,
nqdunpack()
removes instead what an unpack of the same file wrote
to dir, then dir when it is
empty; nothing else is removed.
why, when not NULL,
gets a sentence (cap bytes) on what was refused.
Format
"noqtis-bundle-1\n" 16 bytes
then per file: path length 2 bytes, big-endian, 1 to 4096
path UTF-8, a capsule path
size 8 bytes, big-endian
bytes size bytes
then the end: 0x00 0x00
RETURN VALUES
NQOK; NQEARG for a
NULL argument, files or
rm not 0 or 1, or files 0 for a
capsule that lists no data record; NQEIO when
file exists (nqdpack()),
dir exists (nqdunpack()), or a
file cannot be read or written; NQEDEC and
NQELIM for a bundle refused as above;
NQEMEM.
SEE ALSO
noqtis-check(1), noqtis-export(1), noqtis-pack(1), nqchk(3), nqfiles(3), noqtis-capsule(5)