From 17c66cc2d343de61ddd40693d2890cb2fd01f166 Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Fri, 13 Aug 2021 20:46:43 -0400 Subject: [PATCH] Misc: Fix lastpath updating when using --elf cmdline --- pcsx2/gui/AppInit.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index ef9f3365f1..af1e443127 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -472,8 +472,24 @@ bool Pcsx2App::OnInit() else if (Startup.SysAutoRunElf) { g_Conf->EmuOptions.UseBOOT2Injection = true; - g_Conf->Folders.RunELF = wxFileName(Startup.ElfFile).GetPath(); - sApp.SysExecute(Startup.CdvdSource, Startup.ElfFile); + + // wxPATH_NATIVE is broken on msw, it can delete the first directory after the volume + // EX: P://dir1/dir2/elf.elf -> P://dir2/ ??? +#ifdef _WIN32 + wxFileName elfFile = wxFileName(Startup.ElfFile, wxPATH_WIN); +#else + wxFileName elfFile = wxFileName(Startup.ElfFile, wxPATH_NATIVE); +#endif + + if (!elfFile.FileExists()) + { + wxMessageBox(wxString::Format(_("Specified elf file %s does not exist!"), Startup.ElfFile), "PCSX2", wxICON_ERROR); + } + else + { + g_Conf->Folders.RunELF = elfFile.GetPath(); + sApp.SysExecute(Startup.CdvdSource, Startup.ElfFile); + } } else if (Startup.SysAutoRunIrx) {