Difference between revisions of "Shell.programs"
From ComputerCraft Wiki
Digipenguin (Talk | contribs) |
Digipenguin (Talk | contribs) |
||
Line 1: | Line 1: | ||
Shell.programs is a shell command used in the dir command in default CC | Shell.programs is a shell command used in the dir command in default CC | ||
− | function shell.programs( _bIncludeHidden ) | + | <nowiki>function shell.programs( _bIncludeHidden ) |
local tItems = {} | local tItems = {} | ||
Line 25: | Line 25: | ||
table.sort( tItemList ) | table.sort( tItemList ) | ||
return tItemList | return tItemList | ||
− | end | + | end</nowiki> |
− | + | ||
− | + |
Revision as of 09:56, 16 April 2013
Shell.programs is a shell command used in the dir command in default CC
function shell.programs( _bIncludeHidden ) local tItems = {} -- Add programs from the path for sPath in string.gmatch(sPath, "[^:]+") do sPath = shell.resolve( sPath ) if fs.isDir( sPath ) then local tList = fs.list( sPath ) for n,sFile in pairs( tList ) do if not fs.isDir( fs.combine( sPath, sFile ) ) and (_bIncludeHidden or string.sub( sFile, 1, 1 ) ~= ".") then tItems[ sFile ] = true end end end end -- Sort and return local tItemList = {} for sItem, b in pairs( tItems ) do table.insert( tItemList, sItem ) end table.sort( tItemList ) return tItemList end