Thank you for your answers.
So the process would go like this:
- get the working directory, this is also the mount point for the OPK
- read /proc/mounts to find the loop device (/dev/loop<N>) associated with the mount point
- find the image path associated with the loop device, this is the OPK file
- look for the data relative to the OPK path
The third step can be done using an ioctl specific to loop mounts, see the query_loop function of busybox for an example.
If you really want to store something on the external SD card, I've put something together that will find the first mountpoint for the first partition of the external SD card:
mount | grep -m1 /dev/mmcblk1p1 | cut -d " " -f 3
I was expecting something simpler like "the external SD card can be accessed through this fixed path".
If a maintainer of the GCW Zero operating system goes through this post: for the next version, could you automagically mount it for everyone so that it can be accessed through /media/extsdcard or /mnt/extsdcard ?
Coding it to always look for the data on the external SD card would prevent people from installing Quake on the internal storage. It would be better to look for the data relative to the OPK's location.
I'd suggest providing the choice to use either path (checking the internal SD first, then external, something like that).
What's usually done is putting the data on the internal memory, like:
It already checks the internal SD for .pak files, in /media/data/Quake2 as specified in http://wiki.surkow.com/Understanding_the_directory_structure
. The Quake 2 engine can check multiple paths to find its files, it's just a few lines to add.
I thought it was cleaner to allow it to run independently on SD cards you can swap. Quake 2 data take something like 630 MB with all mission packs and HQ textures, a user could prefer to not fill the internal SD card with this.
So I decided to not change the current behavior. When using an OPK, the data files must be installed in /media/data/Quake2 in the internal SD card.
If a user wants to put data on the external SD card, he will have to copy the binaries (not the OPK) in the same directory.
I will provide both the OPK and the binaries (with the source code obviously).
All written files (configuration, logs, downloaded maps and skins) are put in "/media/home/.local/share/Thenesis/Quake2".
This is the path given by SDL2.