The file format is currently very simple. An archive starts with a line containing the number of entries. This is followed by a file name, then the file size in bytes. Then data for the file, a newline, and then any other files.
It's not robust, it's not scalable, and it's definitely not a thing that most people should use. But it's simple, and works well enough for my small tasks.
#Entries filename length ... filename length ...
The output file handle is stored in the Out variable.
I define file:put to write to the Out file. This will be mapped in place of c:put later.
Each entry has a file name, size, and data. These words write the relevant information to the archive.
The top level part gets the filename for the archive and stores the file pointer in Out.
Then I replace c:put with file:put so I can just use the standard output words to write to the archive.
The first line in the archive is the number of files in the archive.
Then loop over the files, copying them in
And cleanup by reverting c:put and closing the archive file.