mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 03:09:47 +12:00
Deduplicate some code
This commit is contained in:
parent
d4594446bd
commit
6e48c7fbdd
2 changed files with 15 additions and 5 deletions
|
@ -230,6 +230,10 @@ void ExtSaveDataArchive::clear(const FSPath& path) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtSaveDataArchive::saveIcon(const std::vector<u8>& data) const {
|
void ExtSaveDataArchive::saveIcon(const std::vector<u8>& data) const {
|
||||||
|
if (data.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const fs::path iconPath = IOFile::getAppData() / backingFolder / "icon";
|
const fs::path iconPath = IOFile::getAppData() / backingFolder / "icon";
|
||||||
IOFile file(iconPath, "wb");
|
IOFile file(iconPath, "wb");
|
||||||
file.setSize(data.size());
|
file.setSize(data.size());
|
||||||
|
|
|
@ -572,22 +572,28 @@ void FSService::createExtSaveData(u32 messagePointer) {
|
||||||
.duplicateData = false
|
.duplicateData = false
|
||||||
};
|
};
|
||||||
FSPath path = readPath(PathType::Binary, messagePointer + 4, 32);
|
FSPath path = readPath(PathType::Binary, messagePointer + 4, 32);
|
||||||
FSPath smdh = readPath(PathType::Binary, smdhPointer, smdhSize);
|
|
||||||
|
|
||||||
|
ExtSaveDataArchive* selected = nullptr;
|
||||||
switch(mediaType) {
|
switch(mediaType) {
|
||||||
case MediaType::NAND:
|
case MediaType::NAND:
|
||||||
sharedExtSaveData_nand.format(path, info);
|
selected = &sharedExtSaveData_nand;
|
||||||
sharedExtSaveData_nand.saveIcon(smdh.binary);
|
|
||||||
break;
|
break;
|
||||||
case MediaType::SD:
|
case MediaType::SD:
|
||||||
extSaveData_sdmc.format(path, info);
|
selected = &extSaveData_sdmc;
|
||||||
extSaveData_sdmc.saveIcon(smdh.binary);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Helpers::warn("FS::CreateExtSaveData - Unhandled ExtSaveData MediaType %d", static_cast<s32>(mediaType));
|
Helpers::warn("FS::CreateExtSaveData - Unhandled ExtSaveData MediaType %d", static_cast<s32>(mediaType));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected != nullptr) {
|
||||||
|
selected->format(path, info);
|
||||||
|
if(smdhSize > 0) {
|
||||||
|
const FSPath smdh = readPath(PathType::Binary, smdhPointer, smdhSize);
|
||||||
|
selected->saveIcon(smdh.binary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x0851, 1, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x0851, 1, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue