Attempting to rename all files without breaking

This commit is contained in:
Alessandro Proto 2024-08-20 18:45:28 +02:00
parent 1937b0ef79
commit f48288f1a3
6 changed files with 707 additions and 734 deletions

View file

@ -83,7 +83,7 @@ function convert(cfgfile)
for _, v in pairs(lines) do
local tmp
local tmp2 = ""
for match in string.gmatch(v, "[^\=]+") do
for match in string.gmatch(v, "[^\\=]+") do
if tmp then
tmp2 = tmp2..match
else

View file

@ -10,50 +10,33 @@ local function crash(err)
term.setCursorBlink(false)
term.setBackgroundColor(colors.white)
term.clear()
term.setCursorPos(1,1)
term.setCursorPos(1, 1)
term.setTextColor(colors.black)
if not err then
err = "Undefined Error"
end
print("sPhone got an error :(\n")
term.setTextColor(colors.red)
print(err)
print(debug.traceback(err))
term.setTextColor(colors.black)
print("")
if sPhone.version then
print("sPhone "..sPhone.version)
print("sPhone " .. sPhone.version)
end
print("Computer ID: "..os.getComputerID())
if _CC_VERSION then
print("CC Version: ".._CC_VERSION)
print("MC Version: ".._MC_VERSION)
elseif _HOST then
print("Host: ".._HOST)
else
print("CC Version: Under 1.74")
print("MC Version: Undefined")
term.setTextColor(colors.red)
print("Update CC to 1.74 or higher")
term.setTextColor(colors.black)
end
print("LUA Version: ".._VERSION)
if _LUAJ_VERSION then
print("LUAJ Version: ".._LUAJ_VERSION)
end
print("Contact sPhone devs:")
print("GitHub: SertexTeam/sPhone")
print("Thanks for using sPhone")
print("Press any key")
repeat
sleep(0)
until os.pullEvent("key")
if not sPhone.devMode then
_G.term = nil
os.reboot()
end
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,1)
term.setCursorPos(1, 1)
sleep(0.1)
shell.run("/rom/programs/shell")
end
@ -62,7 +45,7 @@ local function recovery()
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.clear()
term.setCursorPos(1,1)
term.setCursorPos(1, 1)
print("sPhone Recovery")
print("[1] Hard Reset")
print("[2] Update sPhone")
@ -78,21 +61,25 @@ local function recovery()
if not fs.isReadOnly(v) then
if fs.isDir(v) then
shell.setDir(v)
for k, v in pairs(fs.list("/"..v)) do
for k, v in pairs(fs.list("/" .. v)) do
fs.delete(v)
print("Removed "..shell.dir().."/"..v)
print("Removed " .. shell.dir() .. "/" .. v)
end
shell.setDir(shell.resolve(".."))
end
fs.delete(v)
print("Removed "..v)
print("Removed " .. v)
end
end
print("Installing sPhone...")
sleep(0.5)
setfenv(loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),getfenv())()
setfenv(
loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),
getfenv())()
elseif k == 3 then
setfenv(loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),getfenv())()
setfenv(
loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),
getfenv())()
elseif k == 4 then
fs.delete("/.sPhone/config")
fs.delete("/.sPhone/cache")
@ -109,33 +96,33 @@ local function recovery()
end
end
term.setBackgroundColor(colors.white)
term.setCursorPos(1,1)
term.clear()
term.setTextColor(colors.black)
print("Sertex")
if fs.exists("/.sPhone/interfaces/bootImage") then
local bootImage = paintutils.loadImage("/.sPhone/interfaces/bootImage")
paintutils.drawImage(bootImage, 11,7)
else
print("Missing bootImage")
end
local w, h = term.getSize()
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.setCursorPos(1,h)
write("Press ALT to recovery mode")
local bootTimer = os.startTimer(1)
while true do
local e,k = os.pullEvent()
if e == "key" and k == 56 then
recovery()
break
elseif e == "timer" and k == bootTimer then
safemode = false
break
end
term.setBackgroundColor(colors.white)
term.setCursorPos(1, 1)
term.clear()
term.setTextColor(colors.black)
print("Sertex")
if fs.exists("/.sPhone/interfaces/bootImage") then
local bootImage = paintutils.loadImage("/.sPhone/interfaces/bootImage")
paintutils.drawImage(bootImage, 11, 7)
else
print("Missing bootImage")
end
local w, h = term.getSize()
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.setCursorPos(1, h)
write("Press ALT to recovery mode")
local bootTimer = os.startTimer(1)
while true do
local e, k = os.pullEvent()
if e == "key" and k == 56 then
recovery()
break
elseif e == "timer" and k == bootTimer then
safemode = false
break
end
end
if not fs.exists("/.sPhone/sPhone") then
printError("sPhone not installed")
@ -143,12 +130,12 @@ if not fs.exists("/.sPhone/sPhone") then
return
end
local runningOnStartup
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,1)
term.setCursorPos(1, 1)
term.setTextColor(colors.white)
if sPhone then
@ -161,7 +148,7 @@ if not pocket or not term.isColor() then
return
end
local tArgs = {...}
local tArgs = { ... }
local argData = {
["-u"] = false,
@ -169,29 +156,35 @@ local argData = {
}
if #tArgs > 0 then
while #tArgs > 0 do
local tArgs = table.remove(tArgs, 1)
if argData[tArgs] ~= nil then
argData[tArgs] = true
end
end
while #tArgs > 0 do
local tArgs = table.remove(tArgs, 1)
if argData[tArgs] ~= nil then
argData[tArgs] = true
end
end
end
if argData["-u"] then
print("Getting installer...")
setfenv(loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),getfenv())()
--setfenv(loadstring(http.get("https://raw.githubusercontent.com/SertexTeam/sPhone/master/src/installer.lua").readAll()),_ENV)()
end
os.pullEvent = os.oldPullEvent
local ok, err = pcall(function()
setfenv(loadfile("/.sPhone/sPhone"), setmetatable({
crash = crash,
safemode = safemode,
}, {__index = getfenv()}))()
end)
local func, err = loadfile("/.sPhone/sPhone.lua", "t", setmetatable({
crash = crash,
safemode = safemode,
}, { __index = _ENV }))
if not func then
crash(err)
os.shutdown()
return
end
local ok, err = pcall(func)
if not ok then
crash(err)
end
_G.term = nil -- The OS ends here - This string force to crash the pda to shutdown
os.shutdown()

View file

@ -7,29 +7,29 @@ local old = os.pullEvent
os.pullEvent = os.pullEventRaw
local files = {
["src/init.lua"] = "/.sPhone/init",
["src/sPhone.lua"] = "/.sPhone/sPhone",
["src/init.lua"] = "/.sPhone/init.lua",
["src/sPhone.lua"] = "/.sPhone/sPhone.lua",
["install.lua"] = "/.sPhone/update",
["install.lua"] = "/.sPhone/update.lua",
["LICENSE"] = "/.sPhone/LICENSE",
["src/apis/sha256.lua"] = "/.sPhone/apis/sha256",
["src/apis/visum.lua"] = "/.sPhone/apis/visum",
["src/apis/base64.lua"] = "/.sPhone/apis/base64",
["src/apis/config.lua"] = "/.sPhone/apis/config",
["src/apis/task.lua"] = "/.sPhone/apis/task",
["src/apis/temp.lua"] = "/.sPhone/apis/temp",
["src/apis/aes.lua"] = "/.sPhone/apis/aes",
["src/apis/bigfont.lua"] = "/.sPhone/apis/bigfont",
["src/apis/sha256.lua"] = "/.sPhone/apis/sha256.lua",
["src/apis/visum.lua"] = "/.sPhone/apis/visum.lua",
["src/apis/base64.lua"] = "/.sPhone/apis/base64.lua",
["src/apis/config.lua"] = "/.sPhone/apis/config.lua",
["src/apis/task.lua"] = "/.sPhone/apis/task.lua",
["src/apis/temp.lua"] = "/.sPhone/apis/temp.lua",
["src/apis/aes.lua"] = "/.sPhone/apis/aes.lua",
["src/apis/bigfont.lua"] = "/.sPhone/apis/bigfont.lua",
["src/bin/wget.lua"] = "/bin/wget",
["src/bin/halt.lua"] = "/bin/halt",
["src/bin/echo.lua"] = "/bin/echo",
["src/bin/wget.lua"] = "/bin/wget.lua",
["src/bin/halt.lua"] = "/bin/halt.lua",
["src/bin/echo.lua"] = "/bin/echo.lua",
["src/sdk/build.lua"] = "/bin/build",
["src/sdk/build.lua"] = "/bin/build.lua",
["src/system/vfs.lua"] = "/.sPhone/system/vfs",
["src/system/vfs.lua"] = "/.sPhone/system/vfs.lua",
["src/apps/spks/appList.spk"] = "/.sPhone/apps/system/appList.spk",
["src/apps/spks/chat.spk"] = "/.sPhone/apps/system/chat.spk",

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
if not fs.exists("/.sPhone/init") then
if not fs.exists("/.sPhone/init.lua") then
printError("sPhone not found")
return
end
shell.run("/.sPhone/init", "-s")
shell.run("/.sPhone/init.lua", "-s")

View file

@ -168,7 +168,7 @@ function fs.exists(path)
return fs.getProxy(path).exists(fs.getProxiedPath(path))
end
function fs.combine(path1, path2)
return nativefs.combine(path1, path2)
return nativefs.combine(path1, path2 or "")
end
function fs.getName(path)
path = fs.cleanPath(path)