Difference between revisions of "Shell.programs"

From ComputerCraft Wiki
Jump to: navigation, search
({{delete}} :: does this even exist in CC; and; why is it blank?)
Line 1: Line 1:
{{delete|a) does this even exist in CC; and; b) why is it blank?. ''[[User:AfterLifeLochie|AfterLifeLochie]] 01:20, 29 November 2012 (MSK)''}}
+
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
 +
--[[User:Digipenguin|Digipenguin]] 13:55, 16 April 2013 (MSK)

Revision as of 09:55, 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 --Digipenguin 13:55, 16 April 2013 (MSK)