Page 1 of 1

FS read files from db via script?

Posted: 21 Dec 2017, 20:10
by sLoPpYdOtBiGhOlE
Hi,
Could anyone please point me to an example of using FS functions to read a packed script or other file?
I've been rummaging through the base CoC scripts, but haven't found what I'm looking for yet.

For example I can use getFS():file_list_open() and it returns a list of all the packed file names in a given directory eg: $game_scripts$.
But how do read a packed file in the list and write it to my harddrive.

I've played with io.open()/read()/write()/Close() which work fine to open and read files that are already unpacked on my drive.

Basically I'm checking if a game script exists unpacked and has been modified.
I use io:open() check if it's unpacked, if so read it, modify if needed.

If the script does not exist unpacked then read the packed version, modify the read data then write the script to drive (I haven't worked this out).