Remove untested icon code

This commit is contained in:
wheremyfoodat 2024-03-08 17:44:16 +02:00
parent a711236307
commit ee4a85aa4a
4 changed files with 2 additions and 76 deletions

View file

@ -23,8 +23,6 @@ public:
void format(const FSPath& path, const FormatInfo& info) override;
Rust::Result<FormatInfo, HorizonResult> getFormatInfo(const FSPath& path) override;
void clear(const FSPath& path) const;
void saveIcon(const std::vector<u8>& data) const;
Rust::Result<std::vector<u8>, HorizonResult> loadIcon() const;
std::filesystem::path getFormatInfoPath(const FSPath& path) const;
std::filesystem::path getUserDataPath() const;

View file

@ -42,7 +42,6 @@ class FSService {
Rust::Result<Handle, HorizonResult> openDirectoryHandle(ArchiveBase* archive, const FSPath& path);
std::optional<Handle> openFileHandle(ArchiveBase* archive, const FSPath& path, const FSPath& archivePath, const FilePerms& perms);
FSPath readPath(u32 type, u32 pointer, u32 size);
void writePointer(const u8* data, u32 pointer, u32 size);
const EmulatorConfig& config;

View file

@ -229,32 +229,6 @@ void ExtSaveDataArchive::clear(const FSPath& path) const {
fs::remove(formatInfoPath);
}
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());
file.writeBytes(data.data(), data.size());
file.flush();
file.close();
}
Rust::Result<std::vector<u8>, HorizonResult> ExtSaveDataArchive::loadIcon() const {
const fs::path iconPath = IOFile::getAppData() / backingFolder / "icon";
IOFile file(iconPath, "rb");
const s32 size = static_cast<s32>(file.size().value_or(-1));
if (size <= 0) {
return Err(Result::FS::NotFoundInvalid);
}
std::vector<u8> icon(size);
file.readBytes(icon.data(), size);
return Ok(icon);
}
std::filesystem::path ExtSaveDataArchive::getFormatInfoPath(const FSPath& path) const {
return IOFile::getAppData() / "FormatInfo" / (getExtSaveDataPathFromBinary(path) + ".format");
}

View file

@ -164,12 +164,6 @@ FSPath FSService::readPath(u32 type, u32 pointer, u32 size) {
return FSPath(type, data);
}
void FSService::writePointer(const u8* data, u32 pointer, u32 size) {
for (u32 i = 0; i < size; i++) {
mem.write8(pointer + i, data[i]);
}
}
void FSService::handleSyncRequest(u32 messagePointer) {
const u32 command = mem.read32(messagePointer);
switch (command) {
@ -204,7 +198,6 @@ void FSService::handleSyncRequest(u32 messagePointer) {
case FSCommands::SetPriority: setPriority(messagePointer); break;
case FSCommands::SetThisSaveDataSecureValue: setThisSaveDataSecureValue(messagePointer); break;
case FSCommands::AbnegateAccessRight: abnegateAccessRight(messagePointer); break;
case FSCommands::ReadExtSaveDataIcon: readExtSaveDataIcon(messagePointer); break;
case FSCommands::TheGameboyVCFunction: theGameboyVCFunction(messagePointer); break;
default: Helpers::panic("FS service requested. Command: %08X\n", command);
}
@ -577,52 +570,14 @@ void FSService::createExtSaveData(u32 messagePointer) {
if (selected != nullptr) {
selected->format(path, info);
if (smdhSize > 0 && smdhPointer != 0) {
const FSPath smdh = readPath(PathType::Binary, smdhPointer, smdhSize);
selected->saveIcon(smdh.binary);
}
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);
}
void FSService::readExtSaveDataIcon(u32 messagePointer) {
log("FS::ReadExtSaveDataIcon\n");
const u8 mediaType = mem.read8(messagePointer + 4);
const u64 saveID = mem.read64(messagePointer + 8); // todo: <-- is this used?
const u32 smdhSize = mem.read32(messagePointer + 20);
const u32 smdhPointer = mem.read32(messagePointer + 28);
ExtSaveDataArchive* selected = nullptr;
switch(mediaType) {
case MediaType::NAND:
selected = &sharedExtSaveData_nand;
break;
case MediaType::SD:
selected = &extSaveData_sdmc;
break;
default:
Helpers::warn("FS::ReadExtSaveDataIcon - Unhandled ExtSaveData MediaType %d", static_cast<s32>(mediaType));
break;
}
mem.write32(messagePointer, IPC::responseHeader(0x0853, 1, 0));
Rust::Result<std::vector<u8>, HorizonResult> data = selected == nullptr ? Err(Result::FS::NotFoundInvalid) : selected->loadIcon();
if (data.isErr() || smdhSize == 0 || smdhPointer == 0) {
mem.write32(messagePointer + 4, data.unwrapErr());;
mem.write32(messagePointer + 8, 0);
} else {
const std::vector<u8> buffer = data.unwrap<std::vector<u8>>();
const u32 copySize = std::min(smdhSize, static_cast<u32>(buffer.size()));
writePointer(buffer.data(), smdhPointer, copySize);
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, copySize);
}
}
void FSService::formatThisUserSaveData(u32 messagePointer) {
log("FS::FormatThisUserSaveData\n");