Difference between revisions of "Fs.list"

From ComputerCraft Wiki
Jump to: navigation, search
(Add a description)
Line 1: Line 1:
 +
{{lowercase}}
 
{{Function
 
{{Function
 
|name=fs.list
 
|name=fs.list
 
|args=[[string (type)|string]] path
 
|args=[[string (type)|string]] path
 
|api=fs
 
|api=fs
|returns=[[table (type)|table]] list of files and folders in that path
+
|returns=[[table (type)|table]] list of files and folders in <var>path</var>, which must be a directory
 +
|desc=Returns a list of all the files contained in a directory
 
|examples=
 
|examples=
 
{{Example
 
{{Example
 
|desc=Displays a list of all files and folders in the root directory of a computer
 
|desc=Displays a list of all files and folders in the root directory of a computer
|code=for k,v in ipairs(fs.list("/")) do
+
|code=for k, v in ipairs(fs.list("")) do
 
   print(v)
 
   print(v)
 
  end
 
  end
|output=A list of all files and folders in /
+
|output=A list of all files and folders in the root directory
 
}}
 
}}
 
}}
 
}}

Revision as of 03:46, 12 March 2012


Grid Redstone.png  Function fs.list
Returns a list of all the files contained in a directory
Syntax fs.list(string path)
Returns table list of files and folders in path, which must be a directory
Part of ComputerCraft
API fs

Examples

Grid paper.png  Example
Displays a list of all files and folders in the root directory of a computer
Code
for k, v in ipairs(fs.list("")) do
 print(v)
end
Output A list of all files and folders in the root directory