Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
blawar committed Oct 25, 2019
1 parent 76c210b commit 522b213
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Goldleaf/Include/nsp/nsp_PFS0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace nsp
u64 GetFileSize(u32 Index);
void SaveFile(u32 Index, fs::Explorer *Exp, pu::String Path);
u32 GetFileIndexByName(pu::String File);

static const u32 INVALID_FILE = 0xFFFFFFFF;
private:
pu::String path;
fs::Explorer *gexp;
Expand Down
2 changes: 1 addition & 1 deletion Goldleaf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ VER_MINOR := 7
VER_MICRO := 3

APP_TITLE := GoldBricks
APP_AUTHOR := XorTroll
APP_AUTHOR := XorWar
APP_VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)
APP_TITLEID := 050032A5CF12E000

Expand Down
2 changes: 2 additions & 0 deletions Goldleaf/Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void Initialize()
if(R_FAILED(setInitialize())) exit(1);
if(R_FAILED(setsysInitialize())) exit(1);
if(R_FAILED(usb::comms::Initialize())) exit(1);
if(R_FAILED(splCryptoInitialize())) exit(1);
if(R_FAILED(splInitialize())) exit(1);
if(R_FAILED(bpcInitialize())) exit(1);
if(R_FAILED(nifmInitialize())) exit(1);
Expand All @@ -69,6 +70,7 @@ void Finalize()
delete sdcd;
bpcExit();
splExit();
splCryptoExit();
usb::comms::Exit();
setsysExit();
setExit();
Expand Down
26 changes: 19 additions & 7 deletions Goldleaf/Source/nsp/nsp_Installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,26 +295,38 @@ namespace nsp
NcmNcaId curid = rnca.ContentId;
pu::String ncaname = hos::ContentIdAsString(curid);
if(rnca.Type == ncm::ContentType::Meta) ncaname += ".cnmt";
ncaname += ".nca";
u32 idxncaname = nspentry.GetFileIndexByName(ncaname);

u32 idxncaname;

if((idxncaname = nspentry.GetFileIndexByName(ncaname + ".nca")) != PFS0::INVALID_FILE)
{
ncaname += ".nca";
}
else if((idxncaname = nspentry.GetFileIndexByName(ncaname + ".ncz")) != PFS0::INVALID_FILE)
{
ncaname += ".ncz";
}
else
{
return -1;
}

auto cursize = nspentry.GetFileSize(idxncaname);
totalsize += cursize;
ncaidxs.push_back(idxncaname);
ncanames.push_back(ncaname);
ncasizes.push_back(cursize);
}
NcmContentStorage cst;
ncmOpenContentStorage(storage, &cst);
for(u32 i = 0; i < ncas.size(); i++)
{
ncm::ContentRecord rnca = ncas[i];
NcmNcaId curid = rnca.ContentId;
pu::String ncaname = ncanames[i];
u64 ncasize = ncasizes[i];
u32 idxncaname = ncaidxs[i];

NcmContentStorage cst;
ncmOpenContentStorage(storage, &cst);
ncm::DeletePlaceHolder(&cst, &curid);
ncm::CreatePlaceHolder(&cst, &curid, &curid, ncasize);
NcaWriter writer(curid, &cst);
u64 noff = 0;
u64 szrem = ncasize;
Expand Down Expand Up @@ -345,8 +357,8 @@ namespace nsp
twrittensize += noff;
ncmContentStorageRegister(&cst, &curid, &curid);
ncm::DeletePlaceHolder(&cst, &curid);
serviceClose(&cst.s);
}
serviceClose(&cst.s);
return rc;
}

Expand Down
6 changes: 2 additions & 4 deletions Goldleaf/Source/nsp/nsp_PFS0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,13 @@ namespace nsp

u32 PFS0::GetFileIndexByName(pu::String File)
{
u32 idx = 0;
for(u32 i = 0; i < this->files.size(); i++)
{
if(strcasecmp(this->files[i].Name.AsUTF8().c_str(), File.AsUTF8().c_str()) == 0)
{
idx = i;
break;
return i;
}
}
return idx;
return INVALID_FILE;
}
}

0 comments on commit 522b213

Please sign in to comment.