Re: where is the configuration file on linux
i know where it is, read my first post. putting application data together with configuration files is just not the right way of doing things. there are many reasons against it: multiuser environment, virus protection (a virus without superuser rights can’t corrupt vital files, only the configuration file), system migration (take your home-folder with you and have everything set up equally on each system you’re on), and so on.
are you sure the
only way where the game looks for the Settings.ini is inside the game folder? if so, above way of doing it is as simple as 1-2-3:
Code:
pseudocode:
#get folder to store settings into, save into global variable
if system == LINUX:
override_folder = path.expand("~/.conf/CortexCommand")
else if system == WINDOWS:
override_folder = path.expand("%APPDATA%\CortexCommand)
else if system == OSX:
override_folder = path.expand("~/Library/Application Support/CortexCommand")
#call this to access files the game writes to
def write_file(rel_path):
or_path = path.join(override_folder, rel_path)
if not path.is_file(or_path):
#make all dirs up to the file if they don’t exist
or_dir = path.join(path.split(or_path)[:-1]) #all dirs without file name
path.makedirs(or_dir)
#copy file from game directory (which is the working directory) to the override directory
path.copy(rel_path, or_dir)
return or_path
#call this to get the full path for every data file you want to access
def read_file(rel_path):
if path.is_file(path.join(override_folder, rel_path)):
return path.join(override_folder, rel_path)
else:
return path.join(".", rel_path)
that’s it. if the game wants to write a file with path rel_path, it opens the file pointed to (and probably created) by write_file(rel_path), if it wants only read access, it reads the file read_file(rel_path) points to.