mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 19:44:58 +00: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 {
|
||||
if (data.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fs::path iconPath = IOFile::getAppData() / backingFolder / "icon";
|
||||
IOFile file(iconPath, "wb");
|
||||
file.setSize(data.size());
|
||||
|
|
|
@ -572,22 +572,28 @@ void FSService::createExtSaveData(u32 messagePointer) {
|
|||
.duplicateData = false
|
||||
};
|
||||
FSPath path = readPath(PathType::Binary, messagePointer + 4, 32);
|
||||
FSPath smdh = readPath(PathType::Binary, smdhPointer, smdhSize);
|
||||
|
||||
ExtSaveDataArchive* selected = nullptr;
|
||||
switch(mediaType) {
|
||||
case MediaType::NAND:
|
||||
sharedExtSaveData_nand.format(path, info);
|
||||
sharedExtSaveData_nand.saveIcon(smdh.binary);
|
||||
selected = &sharedExtSaveData_nand;
|
||||
break;
|
||||
case MediaType::SD:
|
||||
extSaveData_sdmc.format(path, info);
|
||||
extSaveData_sdmc.saveIcon(smdh.binary);
|
||||
selected = &extSaveData_sdmc;
|
||||
break;
|
||||
default:
|
||||
Helpers::warn("FS::CreateExtSaveData - Unhandled ExtSaveData MediaType %d", static_cast<s32>(mediaType));
|
||||
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 + 4, Result::Success);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue