Module CorsixTH.CorsixTH.Lua.filesystem

Layer for abstracting away differences in file systems.

In the traditional case, the FileSystem is associated with a path on the actual filesystem, from which all other operations are considered relative.

The FileSystem is also able to delegate operations to the ISO_FS library in the engine for reading / listing files off an ISO image instead of a file system.

Functions

FileSystem:_enumerate () Populate the files and sub_dirs values for the current FileSystem path.
FileSystem:fileExists (virtual_path, ...) Determines if the given path points to a real file.
FileSystem:fileSize (virtual_path, ...) Get the size of the file at the given path.
FileSystem:isIso (name) Test if file name has an .iso or .dmg extension
FileSystem:listFiles (virtual_path, ...) list the files in the given path.
FileSystem:readContents (virtual_path, ...) Return the contents of the file at the given path.
FileSystem:setRoot (physical_path) Set the root physical path for this FileSystem.


Functions

FileSystem:_enumerate ()
Populate the files and sub_dirs values for the current FileSystem path.
FileSystem:fileExists (virtual_path, ...)
Determines if the given path points to a real file.

Parameters:

  • virtual_path (string) a path relative to the FileSystem root.
  • ... (string) the virtual_path may be split into separate arguments for each level in the filesystem.
FileSystem:fileSize (virtual_path, ...)
Get the size of the file at the given path.

Parameters:

  • virtual_path (string) a path relative to the FileSystem root.
  • ... (string) the virtual_path may be split into separate arguments for each level in the filesystem.

Returns:

    (numeric) Number of bytes in the given file. Nil if the file doesn't exist.
FileSystem:isIso (name)
Test if file name has an .iso or .dmg extension

Parameters:

  • name
FileSystem:listFiles (virtual_path, ...)
list the files in the given path.

Parameters:

  • virtual_path (string) a path relative to the FileSystem root.
  • ... (string) the virtual_path may be split into separate arguments for each level in the filesystem.

Returns:

    (object) a map of normalized names to actual names of files.
FileSystem:readContents (virtual_path, ...)
Return the contents of the file at the given path.

Parameters:

  • virtual_path (string) a path relative to the FileSystem root.
  • ... (string) the virtual_path may be split into separate arguments for each level in the filesystem.
FileSystem:setRoot (physical_path)
Set the root physical path for this FileSystem. If the path is an ISO then set the provider. If the path is a directory then set the physical_path and populate the files and sub_dirs.

Parameters:

  • physical_path (string) a path on the filesystem to either a directory or theme hospital ISO file.
generated by LDoc TESTING Last updated 2015-01-01 12:00:00