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 for _, v in pairs(lines) do
local tmp local tmp
local tmp2 = "" local tmp2 = ""
for match in string.gmatch(v, "[^\=]+") do for match in string.gmatch(v, "[^\\=]+") do
if tmp then if tmp then
tmp2 = tmp2..match tmp2 = tmp2..match
else else

View file

@ -10,50 +10,33 @@ local function crash(err)
term.setCursorBlink(false) term.setCursorBlink(false)
term.setBackgroundColor(colors.white) term.setBackgroundColor(colors.white)
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1, 1)
term.setTextColor(colors.black) term.setTextColor(colors.black)
if not err then if not err then
err = "Undefined Error" err = "Undefined Error"
end end
print("sPhone got an error :(\n") print("sPhone got an error :(\n")
term.setTextColor(colors.red) term.setTextColor(colors.red)
print(err) print(debug.traceback(err))
term.setTextColor(colors.black) term.setTextColor(colors.black)
print("") print("")
if sPhone.version then if sPhone.version then
print("sPhone "..sPhone.version) print("sPhone " .. sPhone.version)
end 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") print("Press any key")
repeat repeat
sleep(0) sleep(0)
until os.pullEvent("key") until os.pullEvent("key")
if not sPhone.devMode then if not sPhone.devMode then
_G.term = nil os.reboot()
end end
term.setBackgroundColor(colors.black) term.setBackgroundColor(colors.black)
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1, 1)
sleep(0.1) sleep(0.1)
shell.run("/rom/programs/shell") shell.run("/rom/programs/shell")
end end
@ -62,7 +45,7 @@ local function recovery()
term.setBackgroundColor(colors.white) term.setBackgroundColor(colors.white)
term.setTextColor(colors.black) term.setTextColor(colors.black)
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1, 1)
print("sPhone Recovery") print("sPhone Recovery")
print("[1] Hard Reset") print("[1] Hard Reset")
print("[2] Update sPhone") print("[2] Update sPhone")
@ -78,21 +61,25 @@ local function recovery()
if not fs.isReadOnly(v) then if not fs.isReadOnly(v) then
if fs.isDir(v) then if fs.isDir(v) then
shell.setDir(v) shell.setDir(v)
for k, v in pairs(fs.list("/"..v)) do for k, v in pairs(fs.list("/" .. v)) do
fs.delete(v) fs.delete(v)
print("Removed "..shell.dir().."/"..v) print("Removed " .. shell.dir() .. "/" .. v)
end end
shell.setDir(shell.resolve("..")) shell.setDir(shell.resolve(".."))
end end
fs.delete(v) fs.delete(v)
print("Removed "..v) print("Removed " .. v)
end end
end end
print("Installing sPhone...") print("Installing sPhone...")
sleep(0.5) 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 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 elseif k == 4 then
fs.delete("/.sPhone/config") fs.delete("/.sPhone/config")
fs.delete("/.sPhone/cache") fs.delete("/.sPhone/cache")
@ -109,33 +96,33 @@ local function recovery()
end end
end end
term.setBackgroundColor(colors.white) term.setBackgroundColor(colors.white)
term.setCursorPos(1,1) term.setCursorPos(1, 1)
term.clear() term.clear()
term.setTextColor(colors.black) term.setTextColor(colors.black)
print("Sertex") print("Sertex")
if fs.exists("/.sPhone/interfaces/bootImage") then if fs.exists("/.sPhone/interfaces/bootImage") then
local bootImage = paintutils.loadImage("/.sPhone/interfaces/bootImage") local bootImage = paintutils.loadImage("/.sPhone/interfaces/bootImage")
paintutils.drawImage(bootImage, 11,7) paintutils.drawImage(bootImage, 11, 7)
else else
print("Missing bootImage") print("Missing bootImage")
end end
local w, h = term.getSize() local w, h = term.getSize()
term.setBackgroundColor(colors.white) term.setBackgroundColor(colors.white)
term.setTextColor(colors.black) term.setTextColor(colors.black)
term.setCursorPos(1,h) term.setCursorPos(1, h)
write("Press ALT to recovery mode") write("Press ALT to recovery mode")
local bootTimer = os.startTimer(1) local bootTimer = os.startTimer(1)
while true do while true do
local e,k = os.pullEvent() local e, k = os.pullEvent()
if e == "key" and k == 56 then if e == "key" and k == 56 then
recovery() recovery()
break break
elseif e == "timer" and k == bootTimer then elseif e == "timer" and k == bootTimer then
safemode = false safemode = false
break break
end
end end
end
if not fs.exists("/.sPhone/sPhone") then if not fs.exists("/.sPhone/sPhone") then
printError("sPhone not installed") printError("sPhone not installed")
@ -143,12 +130,12 @@ if not fs.exists("/.sPhone/sPhone") then
return return
end end
local runningOnStartup local runningOnStartup
term.setBackgroundColor(colors.black) term.setBackgroundColor(colors.black)
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1, 1)
term.setTextColor(colors.white) term.setTextColor(colors.white)
if sPhone then if sPhone then
@ -161,7 +148,7 @@ if not pocket or not term.isColor() then
return return
end end
local tArgs = {...} local tArgs = { ... }
local argData = { local argData = {
["-u"] = false, ["-u"] = false,
@ -169,29 +156,35 @@ local argData = {
} }
if #tArgs > 0 then if #tArgs > 0 then
while #tArgs > 0 do while #tArgs > 0 do
local tArgs = table.remove(tArgs, 1) local tArgs = table.remove(tArgs, 1)
if argData[tArgs] ~= nil then if argData[tArgs] ~= nil then
argData[tArgs] = true argData[tArgs] = true
end end
end end
end end
if argData["-u"] then if argData["-u"] then
print("Getting installer...") 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 end
os.pullEvent = os.oldPullEvent os.pullEvent = os.oldPullEvent
local ok, err = pcall(function() local func, err = loadfile("/.sPhone/sPhone.lua", "t", setmetatable({
setfenv(loadfile("/.sPhone/sPhone"), setmetatable({ crash = crash,
crash = crash, safemode = safemode,
safemode = safemode, }, { __index = _ENV }))
}, {__index = getfenv()}))()
end) if not func then
crash(err)
os.shutdown()
return
end
local ok, err = pcall(func)
if not ok then if not ok then
crash(err) crash(err)
end 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 os.pullEvent = os.pullEventRaw
local files = { local files = {
["src/init.lua"] = "/.sPhone/init", ["src/init.lua"] = "/.sPhone/init.lua",
["src/sPhone.lua"] = "/.sPhone/sPhone", ["src/sPhone.lua"] = "/.sPhone/sPhone.lua",
["install.lua"] = "/.sPhone/update", ["install.lua"] = "/.sPhone/update.lua",
["LICENSE"] = "/.sPhone/LICENSE", ["LICENSE"] = "/.sPhone/LICENSE",
["src/apis/sha256.lua"] = "/.sPhone/apis/sha256", ["src/apis/sha256.lua"] = "/.sPhone/apis/sha256.lua",
["src/apis/visum.lua"] = "/.sPhone/apis/visum", ["src/apis/visum.lua"] = "/.sPhone/apis/visum.lua",
["src/apis/base64.lua"] = "/.sPhone/apis/base64", ["src/apis/base64.lua"] = "/.sPhone/apis/base64.lua",
["src/apis/config.lua"] = "/.sPhone/apis/config", ["src/apis/config.lua"] = "/.sPhone/apis/config.lua",
["src/apis/task.lua"] = "/.sPhone/apis/task", ["src/apis/task.lua"] = "/.sPhone/apis/task.lua",
["src/apis/temp.lua"] = "/.sPhone/apis/temp", ["src/apis/temp.lua"] = "/.sPhone/apis/temp.lua",
["src/apis/aes.lua"] = "/.sPhone/apis/aes", ["src/apis/aes.lua"] = "/.sPhone/apis/aes.lua",
["src/apis/bigfont.lua"] = "/.sPhone/apis/bigfont", ["src/apis/bigfont.lua"] = "/.sPhone/apis/bigfont.lua",
["src/bin/wget.lua"] = "/bin/wget", ["src/bin/wget.lua"] = "/bin/wget.lua",
["src/bin/halt.lua"] = "/bin/halt", ["src/bin/halt.lua"] = "/bin/halt.lua",
["src/bin/echo.lua"] = "/bin/echo", ["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/appList.spk"] = "/.sPhone/apps/system/appList.spk",
["src/apps/spks/chat.spk"] = "/.sPhone/apps/system/chat.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") printError("sPhone not found")
return return
end 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)) return fs.getProxy(path).exists(fs.getProxiedPath(path))
end end
function fs.combine(path1, path2) function fs.combine(path1, path2)
return nativefs.combine(path1, path2) return nativefs.combine(path1, path2 or "")
end end
function fs.getName(path) function fs.getName(path)
path = fs.cleanPath(path) path = fs.cleanPath(path)