shaymanjohn / speccyMac

ZX Spectrum emulator for OSX, written in Swift
GNU General Public License v3.0
15 stars 3 forks source link

Add support for snapshots inside ZIP archives #29

Open hippietrail opened 2 years ago

hippietrail commented 2 years ago

I've actually got ZIP parsing and extracting working in pure Swift in a standalone tool. Just need to use that logic to make a new Loader.

hippietrail commented 2 years ago

One problem is the Loader is currently set up only to take a path/URL. The Zip Loader will take a path but then it will have a Data that it will need to pass to the SNA or Z80 loader.

I can just make a version that only does SNA by copying and pasting code from the SNA loader as a proof of concept first.

shaymanjohn commented 2 years ago

I think it might be better to change the SupportedGameTypes enum to be called SupportedFileTypes, and add zip as a case in there - this should ensure drag and drop still works for zip files.

Inside the Loader class we'd still get a URL, but we could add some logic to unzip and extract the first file with a valid file type (as it's possible the zip file could have multiple files) - the loader shouldn't need to change too much if we did it this way, just an extra check for a zip and and an unzip routine which returned the data.

I've previously looked at this for SpeccyMac: https://github.com/marmelroy/Zip

Then we just add it as a dependent package, and can just use it immediately.