Updated for version 3.38


FileIO is an utility class that is meant to bring all file functions into one known class instead of io, SystemFS, and file. It also brings some more useful functions.
Remember that this class is called using a colon not a period.
At the moment, not all functions are supported in Linux. An asterisk will be written near functions to indicate that they don't support Linux. Also, make sure you're using the latest SuperBLT version as it may add support for some functions.



Return Type
Open(String path, String flag)
Opens a file. Pretty much the same as
WriteTo(String path, Any data, String flags)
Opens a file in path and writes into data into it. The flag defaults to w. You may need to change to wb for binary files. Returns true if the file opened successfully and closes the file automatically
ReadFrom(String path, String flags, String method)
Opens a file in path and reads its content using method which defaults to "*all"
ReadConfig(String path, Table tbl)
Opens a custom XML file in path. If tbl is present it will run through the strings in the config and try to convert them into values. For example, if tbl has the value x=1 and in the config we have the string y="$x" it will convert that to 1
ConvertScriptData(String/Binary data, String typ, Boolean clean)
Converts data to a readable table. typ is the type of the data. Either custom_xml, generic_xml, binary, or json. clean cleans the returned table. This is mostly for specific cases with reading custom XMLs as they are prone to repeat values when not needed.
ConvertToScriptData(Table data, String typ, Boolean clean)
Converts table data into one of the types (same as in ConvertScriptData). Clean does the same as in the other function too
ReadScriptData(String path, String typ, Boolean clean)
Same as ConvertScriptData but opens a file in path and converts its data.
WriteScriptData(String path, Table data, String typ, Boolean clean)
Opens a file in path and writes the return of ConvertToScriptData to the file. After path the parameters are the same as in ConvertToScriptData. Returns the same as WriteTo
Exists(String path)
Returns a boolean indicating if the file or directory in path exists
*CanWriteTo(String path)
Returns true if path is writable. At the moment, returns true in Linux regardless
GetFiles(String path)
Returns a table of files in path
GetFolders(String path)
Returns a table of folders in path
FileExists(String file)
Returns true if a file in path file exists
DirectoryExists(String folder)
Return true if a folder in path folder exists


*CopyFileTo(String path, String to_path)
Copies a file from path to to_path
*CopyDirTo(String path, String to_path)
Copies a folder from path to to_path
*CopyFilesToAsync(Table copy_data, Function callback)
An asynchronous copy of files. copy_data should contain tables of file path and path to copy to. Example: . callback is the function that will call if the copy succeeded or failed. The function should look like: function(success, message) end
*CopyToAsync(String path, String to_path, Function callback)
Copies a directory in path to to_path asynchronously. callback is the same as in CopyFilesToAsync
*MoveTo(String path, String to_path)
Moves file from path to to_path. This function can be used as a rename function
*Delete(String path)
Deletes a file or directory in path
*DeleteEmptyFolders(String path, Boolean delete_current)
Deletes empty folders in directory path. delete_current determines if to delete the folder itself if it's empty
MakeDir(String path)
Creates the directory path. (Creates the directory through os.execute in Linux)
LoadLocalization(String path, Boolean overwrite)
Loads a localization file (json) from path. overwrite overwrites existing localization
Last modified 1yr ago