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

@ -18,38 +18,21 @@ local function crash(err)
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)
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()
@ -90,9 +73,13 @@ local function recovery()
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")
@ -179,19 +166,25 @@ 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({
local func, err = loadfile("/.sPhone/sPhone.lua", "t", setmetatable({
crash = crash,
safemode = safemode,
}, {__index = getfenv()}))()
end)
}, { __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",

View file

@ -472,7 +472,6 @@ local function kernel(...)
nPos = nPos + 1
recomplete()
redraw()
elseif sEvent == "paste" then
-- Pasted text
clear()
@ -480,7 +479,6 @@ local function kernel(...)
nPos = nPos + string.len(param)
recomplete()
redraw()
elseif sEvent == "key" then
if param == keys.enter then
-- Enter
@ -490,7 +488,6 @@ local function kernel(...)
redraw()
end
break
elseif param == keys.left then
-- Left
if nPos > 0 then
@ -499,7 +496,6 @@ local function kernel(...)
recomplete()
redraw()
end
elseif param == keys.right then
-- Right
if nPos < string.len(sLine) then
@ -512,7 +508,6 @@ local function kernel(...)
-- Accept autocomplete
acceptCompletion()
end
elseif param == keys.up or param == keys.down then
-- Up or down
if nCompletion then
@ -530,7 +525,6 @@ local function kernel(...)
end
end
redraw()
elseif _tHistory then
-- Cycle history
clear()
@ -560,9 +554,7 @@ local function kernel(...)
end
uncomplete()
redraw()
end
elseif param == keys.backspace then
-- Backspace
if nPos > 0 then
@ -572,7 +564,6 @@ local function kernel(...)
recomplete()
redraw()
end
elseif param == keys.home then
-- Home
if nPos > 0 then
@ -581,7 +572,6 @@ local function kernel(...)
recomplete()
redraw()
end
elseif param == keys.delete then
-- Delete
if nPos < string.len(sLine) then
@ -590,7 +580,6 @@ local function kernel(...)
recomplete()
redraw()
end
elseif param == keys["end"] then
-- End
if nPos < string.len(sLine) then
@ -599,18 +588,14 @@ local function kernel(...)
recomplete()
redraw()
end
elseif param == keys.tab then
-- Tab (accept autocomplete)
acceptCompletion()
end
elseif sEvent == "term_resize" then
-- Terminal resized
w = term.getSize()
redraw()
elseif sEvent == "mouse_click" and _MouseEvent then
if nCompletion then
clear()
@ -689,7 +674,6 @@ local function kernel(...)
end
function sPhone.header(title, butt)
if not title then
title = "sPhone"
end
@ -1092,7 +1076,8 @@ end
local result = {}
local ok, err = pcall(function()
result = {setfenv(loadfile(fs.combine("/.sPhone/apps/spk",_config.id.."/files/".._config.main)), setmetatable({
result = { setfenv(loadfile(fs.combine("/.sPhone/apps/spk", _config.id .. "/files/" .. _config.main)),
setmetatable({
spk = {
getName = function()
return (_config.name or nil)
@ -1146,8 +1131,6 @@ end
"sphone.home",
}
while true do
if not config.read("/.sPhone/config/spklist", "sphone.home") then
sPhone.install("/.sPhone/apps/home.spk")
end
@ -1178,7 +1161,6 @@ end
errorCount = errorCount + 1
end
sleep(0)
end
sPhone.inHome = false
end
@ -1267,7 +1249,6 @@ end
end
while not skipped do
term.setBackgroundColor(sPhone.theme["lock.background"])
term.clear()
term.setCursorPos(1, 1)
@ -1410,7 +1391,6 @@ end
sPhone.winOk("New Update:", newVersion)
end
home()
end
if not sPhone then
kernel({ ... })

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)