local b64data = string.gsub([[ base64 encoded data with linebreaks here ]], "\n", "")
local gzipData = love.filesystem.newFileData(b64data, "file.dat.gz", "base64")
local rawData = love.math.decompress(gzipData, "gzip")
local fileData = love.filesystem.newFileData(rawData, "file.dat", "file")
This works, but I wonder if it is the best way to do this. Is it really necessary to create two FileData objects, or is there a way to decode and decompress in one go?
And what is the name parameter of newFileData() used for? Probably for FileData:getFilename(), but does it have to follow any semantics or conventions? Can I use the same filename multiple times?
love.math.decompress also accepts strings, so you don't need the first FileData.
The name parameters is used... well, whenever a file name/its extension is used to determine the format: when loading images or sound. As most of love's functions accept FileData (and implicitly convert file names or Files to FileData), that is the only way these functions can determine the corresponding file name.
bartbes wrote: ↑Tue Oct 17, 2017 7:38 amlove.math.decompress also accepts strings, so you don't need the first FileData.
But the data is Base64 encoded, and lm.decompress doesn't accept Base64 encoded strings. The only way to go from Base64 to binary is either through newFileData or by doing the decoding myself, right?
The name parameters is used... well, whenever a file name/its extension is used to determine the format: when loading images or sound. As most of love's functions accept FileData (and implicitly convert file names or Files to FileData), that is the only way these functions can determine the corresponding file name.
grump wrote: ↑Tue Oct 17, 2017 7:55 am
But the data is Base64 encoded, and lm.decompress doesn't accept Base64 encoded strings. The only way to go from Base64 to binary is either through newFileData or by doing the decoding myself, right?
My bad, yes, that is the case. In 0.11.0 there is a love.data.decode that does base64 decoding instead.