-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMAutoUpdater.lua
48 lines (44 loc) · 1.37 KB
/
CMAutoUpdater.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local status = true
local appdata_path = utils.get_appdata_path("PopstarDevs", "2Take1Menu")
local filePaths = {
["cheesemenu.lua"] = appdata_path.."\\scripts\\cheesemenu.lua",
["GLTW.lua"] = appdata_path.."\\scripts\\cheesemenu\\libs\\GLTW.lua",
["Get Input.lua"] = appdata_path.."\\scripts\\cheesemenu\\libs\\Get Input.lua",
["CheeseUtilities.lua"] = appdata_path.."\\scripts\\cheesemenu\\libs\\CheeseUtilities.lua",
["Proddy's Script Manager.lua"] = appdata_path.."\\scripts\\cheesemenu\\libs\\Proddy's Script Manager.lua",
}
local responseCode, responseBody = web.get([[https://raw.githubusercontent.com/GhustOne/CheeseMenu/main/aioUpdate.lua]])
if responseCode ~= 200 then
print("Failed to download update.")
status = false
end
local chunk = load(responseBody)
if not chunk then
status = false
return status
end
local updatedFiles = chunk()
if status then
for _, v in pairs(filePaths) do
local currentFile = io.open(v, "a+")
if not currentFile then
status = "ERROR REPLACING"
break
end
currentFile:close()
end
if status ~= "ERROR REPLACING" then
for k, v in pairs(filePaths) do
local currentFile = io.open(v, "w+b")
if currentFile then
currentFile:write(updatedFiles[k])
currentFile:flush()
currentFile:close()
else
status = "ERROR REPLACING"
break
end
end
end
end
return status