Difference between revisions of "Fs (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Cleanup in preparation for creating individual function pages)
Line 4: Line 4:
 
!style="background:#EEE" width="*"|Description
 
!style="background:#EEE" width="*"|Description
 
|-
 
|-
|[[fs.list]]( path )
+
|[[fs.list]](path)
|Lists the directories and files in the given path.
+
|Lists the directories and files in the given directory
 
|-
 
|-
|[[fs.exists]]( path )
+
|[[fs.exists]](path)
|Checks if the given path exists
+
|Checks if a path refers to an existing file or directory
 
|-
 
|-
|[[fs.isDir]]( path )
+
|[[fs.isDir]](path)
|Checks if the given path is a directory.
+
|Checks if a path refers to an existing directory
 
|-
 
|-
|[[fs.isReadOnly]]( path )
+
|[[fs.isReadOnly]](path)
|Checks if you can only read to a directory.
+
|Checks if a path is read-only (i.e. cannot be modified)
 
|-
 
|-
 
|[[fs.getName]]( path )
 
|[[fs.getName]]( path )
|<no description given>
+
|Gets the final component of a pathname
 
|-
 
|-
 
|[[fs.getDrive]]( path )
 
|[[fs.getDrive]]( path )
|<no description given>
+
|Gets the type of storage medium holding a file or directory
 
|-
 
|-
 
|[[fs.makeDir]]( path )
 
|[[fs.makeDir]]( path )
|Makes a directory.
+
|Makes a directory
 
|-
 
|-
|[[fs.move]]( path, path )
+
|[[fs.move]]( fromPath, toPath )
|Moves path 1 to path 2.
+
|Moves a file or directory to a new location
 
|-
 
|-
 
|[[fs.copy]]( path, path )
 
|[[fs.copy]]( path, path )
|Copies path 1 to path 2.
+
|Copies a file or directory to a new location
 
|-
 
|-
 
|[[fs.delete]]( path )
 
|[[fs.delete]]( path )
|Deletes the given path.
+
|Deletes a file or directory
 
|-
 
|-
|[[fs.combine]]( path, localpath )
+
|[[fs.combine]](basePath, localPath)
|Adds the given path and the local path together to make a new path. Like if localpath is C\ and path is programs\, it will make C\programs\ and return it.
+
|Combines two path components, returning a path consisting of the local path nested inside the base path
 
|-
 
|-
 
|[[fs.open]]( path, mode )
 
|[[fs.open]]( path, mode )
|Opens the given path. Modes: "r", "w", "a", "rb", "wb", "ab". Meaning: r: read mode, w: write mode, a: append mode, *b: binary mode.
+
|Opens a file so it can be read or written
 
|}
 
|}
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 03:44, 12 March 2012

The FS API allows you to mess around with the filesystem.

Method name Description
fs.list(path) Lists the directories and files in the given directory
fs.exists(path) Checks if a path refers to an existing file or directory
fs.isDir(path) Checks if a path refers to an existing directory
fs.isReadOnly(path) Checks if a path is read-only (i.e. cannot be modified)
fs.getName( path ) Gets the final component of a pathname
fs.getDrive( path ) Gets the type of storage medium holding a file or directory
fs.makeDir( path ) Makes a directory
fs.move( fromPath, toPath ) Moves a file or directory to a new location
fs.copy( path, path ) Copies a file or directory to a new location
fs.delete( path ) Deletes a file or directory
fs.combine(basePath, localPath) Combines two path components, returning a path consisting of the local path nested inside the base path
fs.open( path, mode ) Opens a file so it can be read or written