mirror of https://github.com/PCSX2/pcsx2.git
Updater: Preserve non-standard exe names on update
This commit is contained in:
parent
05a9a71f4a
commit
a4b598aa15
updater/Windows
|
@ -453,7 +453,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
||||||
const int parent_process_id = StringUtil::FromChars<int>(StringUtil::WideStringToUTF8String(argv[1])).value_or(0);
|
const int parent_process_id = StringUtil::FromChars<int>(StringUtil::WideStringToUTF8String(argv[1])).value_or(0);
|
||||||
const std::string destination_directory = StringUtil::WideStringToUTF8String(argv[2]);
|
const std::string destination_directory = StringUtil::WideStringToUTF8String(argv[2]);
|
||||||
const std::string zip_path = StringUtil::WideStringToUTF8String(argv[3]);
|
const std::string zip_path = StringUtil::WideStringToUTF8String(argv[3]);
|
||||||
std::wstring program_to_launch(argv[4]);
|
const std::wstring program_to_launch(argv[4]);
|
||||||
argv.reset();
|
argv.reset();
|
||||||
|
|
||||||
if (parent_process_id <= 0 || destination_directory.empty() || zip_path.empty() || program_to_launch.empty())
|
if (parent_process_id <= 0 || destination_directory.empty() || zip_path.empty() || program_to_launch.empty())
|
||||||
|
@ -493,7 +493,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteFileW(program_to_launch.c_str()); // In case the new exe has a different name, delete the old one to prevent confusion
|
|
||||||
if (!updater.CommitUpdate())
|
if (!updater.CommitUpdate())
|
||||||
{
|
{
|
||||||
progress.ModalError(
|
progress.ModalError(
|
||||||
|
@ -504,22 +503,26 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
||||||
updater.CleanupStagingDirectory();
|
updater.CleanupStagingDirectory();
|
||||||
updater.RemoveUpdateZip();
|
updater.RemoveUpdateZip();
|
||||||
|
|
||||||
progress.ModalInformation("Update complete.");
|
// Rename the new executable to match the existing one
|
||||||
|
if (std::string actual_exe = updater.FindPCSX2Exe(); !actual_exe.empty())
|
||||||
if (GetFileAttributesW(program_to_launch.c_str()) == INVALID_FILE_ATTRIBUTES)
|
|
||||||
{
|
{
|
||||||
// New executable doesn't match old, try to find the real one...
|
const std::string full_path = destination_directory + FS_OSPATH_SEPARATOR_STR + actual_exe;
|
||||||
if (std::string actual_exe = updater.FindPCSX2Exe(); !actual_exe.empty())
|
progress.DisplayFormattedInformation("Moving '%s' to '%S'", full_path.c_str(), program_to_launch.c_str());
|
||||||
|
const bool ok = MoveFileExW(StringUtil::UTF8StringToWideString(full_path).c_str(),
|
||||||
|
program_to_launch.c_str(), MOVEFILE_REPLACE_EXISTING);
|
||||||
|
if (!ok)
|
||||||
{
|
{
|
||||||
std::string full_path = destination_directory + FS_OSPATH_SEPARATOR_STR + actual_exe;
|
progress.DisplayFormattedModalError("Failed to rename '%s' to %S", full_path.c_str(), program_to_launch.c_str());
|
||||||
program_to_launch = StringUtil::UTF8StringToWideString(full_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
progress.ModalError("Couldn't find PCSX2 in update package, please re-download a fresh version from GitHub.");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progress.ModalError("Couldn't find PCSX2 in update package, please re-download a fresh version from GitHub.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress.ModalInformation("Update complete.");
|
||||||
|
|
||||||
progress.DisplayFormattedInformation("Launching '%s'...",
|
progress.DisplayFormattedInformation("Launching '%s'...",
|
||||||
StringUtil::WideStringToUTF8String(program_to_launch).c_str());
|
StringUtil::WideStringToUTF8String(program_to_launch).c_str());
|
||||||
|
|
Loading…
Reference in New Issue