Shell.programs

From ComputerCraft Wiki
Revision as of 09:55, 16 April 2013 by Digipenguin (Talk | contribs)

Jump to: navigation, search

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

--Digipenguin 13:55, 16 April 2013 (MSK)