Refill WC24 bootstrap files that were left empty

Bootstrap seeding only created missing files, so a WC24 file that had
been emptied (nwc24dl.bin, nwc24fl.bin, misc.bin) stayed at zero bytes
on every boot. WC24 rejects a zero-length download or friend list and
MKW reports that as a save error, which matters now that #7 lets KD
open while offline. A file is re-copied only when it is empty and the
payload's copy is not, so player data is never replaced.

Adapted from nx-mod/wiicompiled-nx d0149e66. That version falls through
to copy_file with copy_options::none, which fails on the existing empty
file; this one overwrites in that case only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018NKSMYZU43wUfYtm1sxGsC
This commit is contained in:
Claude committed 2026-10-05 15:20:02 +00:00
1 parent e49ec771c3
commit 8f725001de
1 file changed
+21 -3
+21 -3
View File
@@ -86,19 +86,37 @@ inline bool CopyBootstrapFile(const std::filesystem::path& sourceRoot,
std::error_code& ec) {
const auto source = sourceRoot / relativePath;
const auto destination = destinationRoot / relativePath;
auto copyOptions = std::filesystem::copy_options::none;
if (std::filesystem::exists(destination, ec)) {
return !ec;
if (ec) {
return false;
}
// Keep whatever the player has, except an empty file where the payload has content. WC24
// rejects a zero-length download or friend list outright and MKW reports that as a save
// error; since seeding only ran for missing files, such a file stayed broken for good.
const auto existingSize = std::filesystem::file_size(destination, ec);
if (ec) {
return false;
}
std::error_code sourceError;
const auto sourceSize = std::filesystem::file_size(source, sourceError);
if (existingSize != 0 || sourceError || sourceSize == 0) {
return true;
}
copyOptions = std::filesystem::copy_options::overwrite_existing;
} else if (ec) {
return false;
}
std::filesystem::create_directories(destination.parent_path(), ec);
if (ec) {
return false;
}
std::filesystem::copy_file(source, destination, std::filesystem::copy_options::none, ec);
std::filesystem::copy_file(source, destination, copyOptions, ec);
return !ec;
}
// Create these WC24 files only for a new profile; never overwrite user data.
// Create these WC24 files for a new profile, or refill one left empty; never overwrite user data.
constexpr std::string_view kBootstrapFiles[] = {
"shared2/wc24/misc.bin",
"shared2/wc24/nwc24dl.bin",