Documentation for sysutils.py

Warning: This documentation was generated from the comments in the source code (using progrutils.documentPyFile()), with a few tweaks, under the principle that poor documentation is better than no documentation. In case of ambiguity, please refer to the code itself.

 

System Utilities for Freedom Force, v.1.4

By Épiméthée, with help from Stumpy

A small collection of functions for Freedom Force and FFX related to file, folder, mod, etc.

 


Mod folder management


getModFolder()

Get the current mod's main folder name (for writing text files, etc.)
Replaces the old MODFOLDER='my folder' manual entry in ffxextras.py.

Note: Alternatively, you could use Stumpy's GetModPath() function in the DATFiles module.


File input/output


updateFile(), writeFile() and readFile()

These were originally released in heightcheck.py. They've been updated to use getModFolder() instead of the MODFOLDER variable. The path has also been made customizable.
Note the use of double backslashes in subFolder parameter

updateFile(fileName, changedVar, changedValue, baseFolder = "", subFolder = "missions\\scripts")

Adds or updates a variable to a text file.
A variable cannot be completely removed, only emptied.
Multilines variables are not supported.
ChangedVar needs to be entered as a string!
If the variable is not found in the file, it will be added at the end of the file.
To use directly in the currently active directory, employ the dot notation:
sysutils.readFile("name of the file.txt", baseFolder=".", subFolder=".\\.")

readFile(fileName, baseFolder = "", subFolder = "missions\\scripts")

writeFile(fileName, content, baseFolder = "", subFolder = "missions\\scripts")

content parameter should be a list