fs.complete

From ComputerCraft Wiki
Jump to: navigation, search


Grid Redstone.png  Function fs.complete
Added by ComputerCraft 1.74, fs.complete() can be passed a partial file or directory name, and returns a numerically indexed table containing strings that could be used to complete it.

If "include files" is set to false, only directory names will be considered. If "include slashes" is set to true, each possible directory name will be represented in the list twice - once with a trailing forward slash (/), and once without (consecutively, and in that order). Both of these optional parameters default to true if omitted.

Note that fs.complete() is case-sensitive, even if the file system it's being used with isn't. fs.find() is a similar function, although it provides matched file / folder names in full.

See also: textutils.complete(), shell.complete(), shell.setCompletionFunction(), shell.completeProgram() and help.completeTopic().
Syntax fs.complete(string file / directory, string parent folder [, boolean include files] [, boolean include slashes])
Returns table completion list
Part of ComputerCraft
API fs

Examples

Grid paper.png  Example
Prints a list of strings that could be combined with "p" to produce file names in the rom/apis directory.
Code
textutils.tabulate( fs.complete( "p", "rom/apis" ) )
Output aintutils arallel eripheral (which could be concatenated to get the names of the paintutils, parallel and peripheral APIs).



Grid paper.png  Example
Generates a table containing all file / folder names located in the rom directory.
Code
for _, match in pairs( fs.complete( "", "rom" ) ) do print( match ) end
Output .

..
apis/
apis
autorun/
autorun
help/
help
programs/
programs

startup