Welcome to PenUltima Online. Click to login or register.

File: File.em

Description: File Access functions
Last Modified: 10/27/2007

File Constants:

// LogToFile constants
const LOG_DATETIME := 1; // log Core-Style DateTimeStr in front of log entry
AppendToFile( filename, morelines )
Parameters:
Name Type
filename string
morelines array of strings
Explanation
Appends to a text file, adding newlines. Creates file if it does not exist.
By default, no package has any file access rights. To grant access, see config/fileaccess.cfg
Return values
1 or error
Errors
"Invalid parameter type"
"Error in filename descriptor"
"No parent path traversal please."
"Access denied"
"Unable to open file: X"
"Error during write."
Related Configs
fileaccess.cfg
FileExists( filename )
Parameters:
Name Type
filename string
Explanation
Checks for the existence of a file based on Filename parameter.
Return values
1 on success
Errors
"Invalid parameter type"
"Error in filename descriptor"
"No parent path traversal please."
Related Configs
fileaccess.cfg
LogToFile( filename, line, flags := 0 )
Parameters:
Name Type
filename String
line String
flags Integer
Explanation
Appends a single line to a text file, adds newlines, creates file if it does not exist.
By default, no package has any file access rights. To grant access, see config/fileaccess.cfg
file.em constants for flags:
const LOG_DATETIME := 1; // log Core-Style DateTimeStr in front of log entry
Return values
1 or error
Errors
"Invalid parameter type"
"Error in filename descriptor"
"No parent path traversal please."
"Access denied"
"Unable to open file: X"
"Error during write."
Related Configs
fileaccess.cfg
ReadFile( filename )
Parameters:
Name Type
filename string
Explanation
Reads a text file, returning the contents as an array of strings, removing newlines.
By default, no package has any file access rights. To grant access, see config/fileaccess.cfg
Return values
returns array of strings
Errors
"Invalid parameter type"
"Error in filename descriptor"
"No parent path traversal please."
"Access denied"
"File not found: X"
Related Configs
fileaccess.cfg
WriteFile( filename, textcontents )
Parameters:
Name Type
filename string
textcontents array of strings
Explanation
Writes a new file to disk, appends newlines, creates file if it does not exist, renames existing file to filename.bak
By default, no package has any file access rights. To grant access, see config/fileaccess.cfg
Return values
1 or error
Errors
"Invalid parameter type"
"Error in filename descriptor"
"No parent path traversal please."
"Access denied"
"File not found: X"
"Error during write."
"Unable to remove filenameX: reasonY
"Unable to rename filenameX: to filenameZ: reasonY
Related Configs
fileaccess.cfg