mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-05 08:39:04 +00:00
Replace file writes with new helper
This commit is contained in:
+1
-12
@@ -92,12 +92,6 @@ bool Extdata::ExtractFile(const std::string& path, std::size_t index) const {
|
|||||||
/// Maximum amount of device files a device directory can hold.
|
/// Maximum amount of device files a device directory can hold.
|
||||||
constexpr u32 DeviceDirCapacity = 126;
|
constexpr u32 DeviceDirCapacity = 126;
|
||||||
|
|
||||||
FileUtil::IOFile file(path, "wb");
|
|
||||||
if (!file) {
|
|
||||||
LOG_ERROR(Core, "Could not open file {}", path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 file_index = index + 1;
|
u32 file_index = index + 1;
|
||||||
u32 sub_directory_id = file_index / DeviceDirCapacity;
|
u32 sub_directory_id = file_index / DeviceDirCapacity;
|
||||||
u32 sub_file_id = file_index % DeviceDirCapacity;
|
u32 sub_file_id = file_index % DeviceDirCapacity;
|
||||||
@@ -120,12 +114,7 @@ bool Extdata::ExtractFile(const std::string& path, std::size_t index) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.WriteBytes(data[0].data(), data[0].size()) != data[0].size()) {
|
return FileUtil::WriteBytesToFile(path, data[0].data(), data[0].size());
|
||||||
LOG_ERROR(Core, "Write data failed (file: {})", path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveFormatInfo Extdata::GetFormatInfo() const {
|
ArchiveFormatInfo Extdata::GetFormatInfo() const {
|
||||||
|
|||||||
+1
-12
@@ -293,18 +293,7 @@ bool SDMCImporter::ImportSystemArchive(u64 id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtil::IOFile target(target_path, "wb");
|
return FileUtil::WriteBytesToFile(target_path, romfs.data(), romfs.size());
|
||||||
if (!target) {
|
|
||||||
LOG_ERROR(Core, "Could not open {}", target_path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.WriteBytes(romfs.data(), romfs.size()) != romfs.size()) {
|
|
||||||
LOG_ERROR(Core, "Failed to write to {}", target_path);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDMCImporter::ImportSysdata(u64 id,
|
bool SDMCImporter::ImportSysdata(u64 id,
|
||||||
|
|||||||
@@ -288,12 +288,8 @@ void UtilitiesDialog::RomFSExtractionTool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto& shared_romfs = Core::LoadSharedRomFS(data);
|
const auto& shared_romfs = Core::LoadSharedRomFS(data);
|
||||||
FileUtil::IOFile dest_file(destination.toStdString(), "wb");
|
return FileUtil::WriteBytesToFile(destination.toStdString(), shared_romfs.data(),
|
||||||
if (dest_file.WriteBytes(shared_romfs.data(), shared_romfs.size()) != shared_romfs.size()) {
|
shared_romfs.size());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user