1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-08 06:43:51 +00:00

Enable the use of startup directories

This commit is contained in:
Lignum 2017-05-10 23:02:08 +02:00
parent 25128dfb66
commit 2e7c9b163d
No known key found for this signature in database
GPG Key ID: 0889206F5A8A700D

View File

@ -209,22 +209,42 @@ if fs.exists( "/rom/autorun" ) and fs.isDir( "/rom/autorun" ) then
end end
end end
local function findStartups( sBaseDir )
local tStartups = nil
local sBasePath = "/" .. fs.combine( sBaseDir, "startup" )
local sStartupNode = shell.resolveProgram( sBasePath )
if sStartupNode then
tStartups = { sStartupNode }
else
if fs.isDir( sBasePath ) then
tStartups = {}
for _,v in pairs( fs.list( sBasePath ) ) do
tStartups[ #tStartups + 1 ] = shell.resolveProgram( "/" .. fs.combine( sBasePath, v ) )
end
end
end
return tStartups
end
-- Run the user created startup, either from disk drives or the root -- Run the user created startup, either from disk drives or the root
local sUserStartup = nil local tUserStartups = nil
if settings.get( "shell.allow_startup" ) then if settings.get( "shell.allow_startup" ) then
sUserStartup = shell.resolveProgram( "/startup" ) tUserStartups = findStartups( "/" )
end end
if settings.get( "shell.allow_disk_startup" ) then if settings.get( "shell.allow_disk_startup" ) then
for n,sName in pairs( peripheral.getNames() ) do for n,sName in pairs( peripheral.getNames() ) do
if disk.isPresent( sName ) and disk.hasData( sName ) then if disk.isPresent( sName ) and disk.hasData( sName ) then
local sDiskStartup = shell.resolveProgram( "/" .. disk.getMountPath( sName ) .. "/startup" ) local startups = findStartups( disk.getMountPath( sName ) )
if sDiskStartup then if startups then
sUserStartup = sDiskStartup tUserStartups = startups
break break
end end
end end
end end
end end
if sUserStartup then if type( tUserStartups ) == "table" then
shell.run( sUserStartup ) table.sort( tUserStartups )
for _,v in pairs( tUserStartups ) do
shell.run( v )
end
end end