Difference between revisions of "Lua API:File System"

From The Powder Toy
Jump to: navigation, search
(Filesystem API)
 
m (Reverted edits by LittleProgramming (talk) to last revision by gamax92)
 
(3 intermediate revisions by 2 users not shown)
Line 38: Line 38:
 
  boolean fs.copy(string path, string newPath)
 
  boolean fs.copy(string path, string newPath)
 
Copies the file "path" to "newPath". This function returns true on success and false on failure.
 
Copies the file "path" to "newPath". This function returns true on success and false on failure.
 +
 +
[[Category:Lua]]

Latest revision as of 07:53, 24 February 2021

The File System API contains functions for creating, deleting, modifying and enumerating files and folders.

Methods

fileSystem.list

table fs.list(string folder)

Returns a table containing a list of files and folders in "folder"

fileSystem.exists

boolean fs.exists(string path)

Returns a boolean indicating whether "path" exists as either a file or folder

fileSystem.isFile

boolean fs.isFile(string path)

Returns a boolean indicating whether "path" exists as a file (i.e not a folder)

fileSystem.isDirectory

boolean fs.isDirectory(string path)

Returns a boolean indicating whether "path" exists as a folder (i.e not a file)

fileSystem.makeDirectory

boolean fs.makeDirectory(string path)

Creates the folder "path", this function is not recursive and won't create parent directories (makeDirectory("parent/child") will fail if "parent" does not exist). This function returns true on success and false on failure.

fileSystem.removeDirectory

boolean fs.removeDirectory(string path)

Removes the empty folder specified by "path". This function returns true on success and false on failure.

fileSystem.removeFile

boolean fs.removeFile(string path)

Removes the file "path". This function returns true on success and false on failure.

fileSystem.move

boolean fs.move(string path, string newPath)

Moves the file or folder specified by "path" to "newPath". This function returns true on success and false on failure.

fileSystem.copy

boolean fs.copy(string path, string newPath)

Copies the file "path" to "newPath". This function returns true on success and false on failure.