Library file

File functions. Allows modification of files.

Functions

append (path, data) Appends a string to the end of a file
createDir (path) Creates a directory
delete (path) Deletes a file
exists (path) Checks if a file exists
read (path) Reads a file from path
write (path, data) Writes to a file


Functions

file_library.append (path, data)
Appends a string to the end of a file

Parameters:

  • path: Filepath relative to data/sf_filedata/. Cannot contain '..'
  • data: String that will be appended to the file.

Return value:

    Error message if applicable
file_library.createDir (path)
Creates a directory

Parameters:

  • path: Filepath relative to data/sf_filedata/. Cannot contain '..'
file_library.delete (path)
Deletes a file

Parameters:

  • path: Filepath relative to data/sf_filedata/. Cannot contain '..'

Return values:

  1. True if successful, nil if error
  2. Error message if applicable
file_library.exists (path)
Checks if a file exists

Parameters:

  • path: Filepath relative to data/sf_filedata/. Cannot contain '..'

Return values:

  1. True if exists, false if not, nil if error
  2. Error message if applicable
file_library.read (path)
Reads a file from path

Parameters:

  • path: Filepath relative to data/sf_filedata/. Cannot contain '..'

Return values:

  1. Contents, or nil if error
  2. Error message if applicable
file_library.write (path, data)
Writes to a file

Parameters:

  • path: Filepath relative to data/sf_filedata/. Cannot contain '..'
  • data:

Return values:

  1. True if OK, nil if error
  2. Error message if applicable

Valid XHTML 1.0!