Hi,
my question rises from a thought I had about my app:
I'd like to add a lot of sound files (around 5000, but they could be more) and I am worried that I would eventually reach some
maximum number of files allowed cap: see here
https://stackoverflow.com/a/2652238/20463613My first thought was to split them in subdirectories, but I wonder if there is a better way to handle that which might even be of easier maintenance for the future and "download friendly".
If I could "pack" like tarball my sound files I will have to handle only one "soundpack" file, and I could easily have this single file available as "additional downloadable content" for the users who are running low on storage space. (my app is less than 10mb, but with sounds it goes up to 50mb and counting).
Unfortunately my knowledge stops here:
Do you think it's worth thinking about this potential issue or I am just being too much pessimistic?
If I am making sense: how could I build a pack of files, keeping an index, so that when my app needs "SOUND00345" it can read directly this sound from the soundpack file based on its index? I guess that this is almost the same that the filesystem does, so maybe I am just thinking about redoing something that already is taken care of..
I've found an untar pure lua library here:
https://github.com/mimetic/tar.lua which works fine in gideros, but the only way to extract a single file from the archive is to parse it all until it finds the file/files inside the archive, and this might be counterproductive if the archive is big because it certainly takes time..
Any idea/suggestion is appreciated
Thank you
Comments
5000 sound files for 50mb imho this should be expected and people won't find this unacceptable?
+ Android storage are quite large nowadays.
Likes: pie
To use it afterwise in Gideros, load the last four bytes of your file and decode them to get the size of your index table, then extract the index table using its size, decode it and lookup the offset/size of your audio file with it. Then use a Buffer loaded with the audio file data to play it.
Likes: pie
I am not yet sure if it's worth the hassle but I tried to follow @hgy29 suggestion as an exercise because there is a lot to learn there for me:
I managed to achieve the concatenation of files and the retrieval from the packed file, but I am missing a point here: I apologize for my ignorance; how to convert an integer to 4 bytes and transform these bytes back?
My google searches couldn't help: I can never get the starting integer back, instead I get bigger numbers and everything goes south...
Thank you
Likes: MoKaLux
EDIT: since luau, you can use string.pack and string.unpack too. https://www.lua.org/manual/5.3/manual.html#6.4.2
Likes: pie
string.encodeValue/decodeValue is not documented anywhere though, I've found it only in a post of yours inside the 80's style demos. Is it a gideros' special? I may still choose the easiest route, but I have a choice now that I didn't have yesterday, and I've learned something in between: "those who never try are sure to fail".
Thank you again!
Likes: MoKaLux, hgy29