Author Topic: LUA file handling on different operating systems  (Read 2065 times)

0 Members and 1 Guest are viewing this topic.

LUA file handling on different operating systems
I was unable to find anything related to this topic besides the Windown 7 UAC discussion in the SCP forum.
So how does the scripting system handle file access on different operating systems and different (potentially protected) folders Freespace may be in? Does the FS engine do the work and I don't have to care about it as long as I create/modify files in the mod folder? Or do I have to save files in something like %appdata% to make sure it runs on Linux/Mac as well?
Here goes scripting and copy paste coding
Freespace RTS Mod
Checkpoint/Shipsaveload script

 

Offline m!m

  • 211
Re: LUA file handling on different operating systems
Without checking the code I'd say that you should just use the CFile interface as that will handle all the necessary work for the creation of the file and it's location. If FS can't create the file in the location you specified then you will receive an invalid file handle and you can act accordingly by printing/showing an error or something similar.
That will also ensure that everything works the same for all supported platforms.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: LUA file handling on different operating systems
im not sure if the system handles files appropriate with reguards to writing files in user writable locations. cfile is kinda smart and will find the file you're trying to open anywhere in the mod hierarchy. however when a script needs to write out a config file or some other kinda file output operation, im really not sure where the file goes, i would assume either fs root or the mod's data folder. such files would ultimately need to be placed in mod specific writable locations. cfile would need to be able to read and write to those locations, and would need to maintain some kind of directory stucture to ensure that different mod's files wouldnt interfere with eachother. like if somone wrote a generic script to save a bunch of data to a file, and this script was used in 2 different mods. the files would need to be in similar mod directories under the game's folder in %appdata%.

most of my testing with file output was done with an admin account so that i could circumvent any write restrictions. this is ok for development but not really something that should be done in a script/mod release. and that was before there was much discussion about really moving to change file handling to the correct way of doing things. this has been a concern to me for some time. the general rule of thumb is to completely overlook scripting when implementing a new feature that changes something in a way that affects scripting. :D this is something which should be avoided in this case in order to ensure scripting doesnt break the rules of the os that the game should be obeying.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 
Re: LUA file handling on different operating systems
That's exactly my problem - the script could be used in different mods. At the moment I use cfile for file creation, output and deletion as well as reading operations and so all files are always in the folder of the active mod and everything is fine. But this will change at some point when the OS doesn't allow me to write anything at this place and redirects it to some %appdata% place. So in the end I'm still not sure how it will handle such situations....
Here goes scripting and copy paste coding
Freespace RTS Mod
Checkpoint/Shipsaveload script