Ability to download data from within the emulated OS
Opened this issue · 2 comments
In #5 @dluciv explored ways to upload data into the emulated OS, and there are some working examples. I'm curious about the opposite; if, say, we create a HyperCard stack inside the emulator, could we copy it onto a disk and then download the disk in the browser environment?
@DrJosh9000 as you seem to have set up the very cool https://hypercardadventures.com/ with the ability to upload a disk at runtime, maybe you had thoughts about downloading data too? Thanks, all.
So, loading/saving disk images on HCA wasn't a huge feat of hacks, just:
(a) coming up with a decent UI for letting the user load and save files to JS memory
(b) the emscripten file API allowing exchange between JS memory and the emscripten filesystem, and
(c) there being a command interface in PCE, which I augmented with some C-side helpers and exported to emscripten
The real trick would be reading and writing individual files (like how Mini vMac has its ImportFl / ExportFl tools), but I didn't get far into the Mini vMac source last time I went looking. Also quirks get in the way of vintage files working in the modern world (legacy encodings, resource forks). Disk images are at least a bit more portable.
This would be much easier to do with my BasiliskII port, as BasiliskII already has the functionality of exposing the host OS filesystem to the emulator: https://github.com/jsdf/macemu
Once you can transfer files to or from the host filesystem, it's just a matter of using the Emscripten filesystem APIs