Add files via upload

Fix an issue where icon0 and game title id cannot be found after the game is deleted.
This commit is contained in:
chinseng85 2020-03-21 21:29:42 +08:00 committed by GitHub
parent 1dc0d6008b
commit de8e673935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,7 @@ end
-- Recover title from homebrew database
function recoverTitle(tid)
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FREAD)
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. "/title.txt", FREAD)
fsize = System.sizeFile(file)
local title = System.readFile(file, fsize)
System.closeFile(file)
@ -61,15 +61,23 @@ end
-- Extracts title name from an SFO file
function extractTitle(file, tid)
local data = System.extractSfo(file)
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. tid .. ".txt") then
System.deleteFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt")
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. tid .. "/title.txt") then
System.deleteFile("ux0:/data/TrackPlugArchive/" .. tid .. "/title.txt")
end
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. ".txt", FCREATE)
local file = System.openFile("ux0:/data/TrackPlugArchive/" .. tid .. "/title.txt", FCREATE)
System.writeFile(file, data.title, string.len(data.title))
System.closeFile(file)
return data.title
end
function copyIcon(titleid)
newFile = System.openFile("ux0:/data/TrackPlugArchive/" .. titleid .. "/icon0.png", FCREATE)
oldFile = System.openFile("ur0:/appmeta/" .. titleid .. "/icon0.png", FREAD)
fileSize = System.sizeFile(oldFile)
icon = System.readFile(oldFile, fileSize)
System.writeFile(newFile, icon, fileSize)
end
function getRegion(titleid)
local regioncode = string.sub(titleid,1,4)
local prefix = string.sub(regioncode,1,2)
@ -145,12 +153,18 @@ for i, file in pairs(tbl) do
local titleid = string.sub(file.name,1,-5)
file.region = getRegion(titleid)
if System.doesFileExist("ur0:/appmeta/" .. titleid .. "/icon0.png") then
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. titleid .. "/icon0.png") then
file.icon = Graphics.loadImage("ux0:/data/TrackPlugArchive/" .. titleid .. "/icon0.png")
elseif System.doesFileExist("ur0:/appmeta/" .. titleid .. "/icon0.png") then
file.icon = Graphics.loadImage("ur0:/appmeta/" .. titleid .. "/icon0.png")
System.createDirectory("ux0:/data/TrackPlugArchive/" .. titleid .. "")
copyIcon(titleid)
else
file.icon = unk
end
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. titleid .. ".txt") then
if System.doesFileExist("ux0:/data/TrackPlugArchive/" .. titleid .. "/title.txt") then
file.title = recoverTitle(titleid)
elseif System.doesFileExist("ux0:/app/" .. titleid .. "/sce_sys/param.sfo") then
file.title = extractTitle("ux0:/app/" .. titleid .. "/sce_sys/param.sfo", titleid)