mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-11 08:30:04 +00:00
Enable the use of startup directories
This commit is contained in:
parent
25128dfb66
commit
2e7c9b163d
@ -209,22 +209,42 @@ if fs.exists( "/rom/autorun" ) and fs.isDir( "/rom/autorun" ) then
|
||||
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
|
||||
local sUserStartup = nil
|
||||
local tUserStartups = nil
|
||||
if settings.get( "shell.allow_startup" ) then
|
||||
sUserStartup = shell.resolveProgram( "/startup" )
|
||||
tUserStartups = findStartups( "/" )
|
||||
end
|
||||
if settings.get( "shell.allow_disk_startup" ) then
|
||||
for n,sName in pairs( peripheral.getNames() ) do
|
||||
if disk.isPresent( sName ) and disk.hasData( sName ) then
|
||||
local sDiskStartup = shell.resolveProgram( "/" .. disk.getMountPath( sName ) .. "/startup" )
|
||||
if sDiskStartup then
|
||||
sUserStartup = sDiskStartup
|
||||
local startups = findStartups( disk.getMountPath( sName ) )
|
||||
if startups then
|
||||
tUserStartups = startups
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if sUserStartup then
|
||||
shell.run( sUserStartup )
|
||||
if type( tUserStartups ) == "table" then
|
||||
table.sort( tUserStartups )
|
||||
for _,v in pairs( tUserStartups ) do
|
||||
shell.run( v )
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user