Lua Application Manager/Install.lua

--Install.lua print('Checking for Install File...')

local directory = "." installstring = ""

local function requireFromRoot(File) local Handle, err = io.open("../"..File..".lua") local String, Funct = "", nil if Handle then String = "require = requireFromRoot\n"..Handle:read("*a") Handle:close Funct = load(String) end --local Funct, err = loadfile(".."..File..".lua") if Funct then local var1 = Funct require = Require return var1 or true else oldrequire(File) end end

lfs = require "lfs"

local files = sys.dir(directory) if files then if #files > 4 then JSON = require("JSON") print(#files - 5 .. " stub(s) found!") local installstring = "" local file = io.open("InstallStub.lua") if type(file) ~= "string" then installstring = installstring..file:read("*a") file:close

local Table = JSON.DecodeJSON(installstring) print("Installing…") local InstallDir = "" lfs.mkdir("Applications") lfs.mkdir("Applications/ScriptEditor") lfs.mkdir("Applications/FileBrowser") lfs.mkdir("Applications/Help") lfs.mkdir("Applications/SampleApp") lfs.mkdir("Applications/RegistryEditor") lfs.mkdir("LAMAPI") for k, v in pairs(Table) do print(k) local file = io.open(k, "w") file:write(v) file:close end require "main" end end end

print("Error Installing File")