Updater: Handle UTF-8 paths when launching at end

This commit is contained in:
Connor McLaughlin 2020-08-06 22:37:40 +10:00
parent f0e3373cb2
commit 7ab521f740
2 changed files with 7 additions and 5 deletions

View file

@ -162,7 +162,8 @@ bool Updater::PrepareStagingDirectory()
if (FileSystem::DirectoryExists(m_staging_directory.c_str()))
{
m_progress->DisplayFormattedWarning("Update staging directory already exists, removing");
if (!RecursiveDeleteDirectory(m_staging_directory.c_str()) || FileSystem::DirectoryExists(m_staging_directory.c_str()))
if (!RecursiveDeleteDirectory(m_staging_directory.c_str()) ||
FileSystem::DirectoryExists(m_staging_directory.c_str()))
{
m_progress->ModalError("Failed to remove old staging directory");
return false;
@ -284,7 +285,7 @@ bool Updater::CommitUpdate()
"%s%c%s", m_staging_directory.c_str(), FS_OSPATH_SEPERATOR_CHARACTER, ftu.destination_filename.c_str());
const std::string dest_file_name = StringUtil::StdStringFromFormat(
"%s%c%s", m_destination_directory.c_str(), FS_OSPATH_SEPERATOR_CHARACTER, ftu.destination_filename.c_str());
m_progress->DisplayFormattedDebugMessage("Moving '%s' to '%s'", staging_file_name.c_str(), dest_file_name.c_str());
m_progress->DisplayFormattedInformation("Moving '%s' to '%s'", staging_file_name.c_str(), dest_file_name.c_str());
#ifdef WIN32
const bool result =
MoveFileExW(StringUtil::UTF8StringToWideString(staging_file_name).c_str(),

View file

@ -37,7 +37,7 @@ int wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
const int parent_process_id = StringUtil::FromChars<int>(StringUtil::WideStringToUTF8String(argv[0])).value_or(0);
const std::string destination_directory = StringUtil::WideStringToUTF8String(argv[1]);
const std::string zip_path = StringUtil::WideStringToUTF8String(argv[2]);
const std::string program_to_launch = StringUtil::WideStringToUTF8String(argv[3]);
const std::wstring program_to_launch(argv[3]);
LocalFree(argv);
if (parent_process_id <= 0 || destination_directory.empty() || zip_path.empty() || program_to_launch.empty())
@ -85,7 +85,8 @@ int wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
progress.ModalInformation("Update complete.");
progress.DisplayFormattedInformation("Launching '%s'...", program_to_launch.c_str());
ShellExecuteA(nullptr, "open", program_to_launch.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
progress.DisplayFormattedInformation("Launching '%s'...",
StringUtil::WideStringToUTF8String(program_to_launch).c_str());
ShellExecuteW(nullptr, L"open", program_to_launch.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
return 0;
}