zesinger / libserum

Cross platform dynamic library code for Serum file format
GNU General Public License v2.0
11 stars 4 forks source link

Unable to uncompress on read-only partition #53

Open jsm174 opened 3 months ago

jsm174 commented 3 months ago

The other day I was trying to show off colorizations using VPX standalone and zedmdos.

This is kinda cool because now Android and iOS can wirelessly send dmd data with no latency.

Since VPX does not send across the cRZ files via dmdserver, the cRZ files needed to be installed locally.

The typical layout of zedmdos is:

Screenshot 2024-06-17 at 8 59 19 PM

The dmdserver.ini file is configured as:

[DMDServer]
AltColor = 1
# Overwrite the AltColorPath sent by the client and set it to a fixed value.
AltColorPath = /boot/configs/altcolor

So the problem we have is /boot/configs/altcolor is a read-only partition, so extract the files in the same directory will not work. Instead, the files need to be extracted to somewhere like /tmp.

We had a similar issue with iOS and leveraged an environment variable called TMPDIR.

I would propose that instead of using TMPDIR for just iOS, we use it for all platforms if it is not null.

I've proved this could work here: https://github.com/zesinger/libserum/commit/f2b5694e6a208fcdd985eaa3a3536b2ae8126088

However I did not test in Windows.

It's also worth noting, that it would be neat to also use just a cROM file from VPX standalone, but I noticed some files extract as cRom and some as cROM. I will put this fix in VPX standalone, however, the extension detection code in libserum needs to be case insensitive:

https://github.com/zesinger/libserum/blob/fc22783f4bb0940c7ad8f8c4b32058f94dda89e3/src/serum-decode.cpp#L620C3-L620C33

mkalkbrenner commented 3 months ago

Good point.

Also on real pinball machines we would have an issue. There, you usually only require one colorization. I that use case it makes no sense to let libserum extract that file into the file system on each start. And such machines simply get turned off. So you don't have a shutdown and a read-only file system with a pre-extracted serum file would be healthier for the SD card.

@zesinger @jsm174 Another approach we should think of: AFAIK the entire serum file gets parsed and loaded into memory. So why do we need to extract it to the file system first? Can't we open a the zipped crz file as stream and extract and parse it into the memory in one step? That would avoid the OS-specific file system handling and would extend the lifetime of storages like SD cards.