From 39d1e21802e6f13cf98a02c692bac3fed31fadeb Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 21 Mar 2014 13:45:26 +0400 Subject: [PATCH] Fix slashes for Windows :p --- rpcs3/Emu/FS/VFS.cpp | 18 ++++++++++++------ rpcs3/Emu/FS/vfsDevice.cpp | 12 +++++++++--- rpcs3/Emu/FS/vfsLocalFile.cpp | 5 +++-- rpcs3/Emu/HDD/HDD.h | 2 +- rpcs3/Emu/System.cpp | 8 ++++---- rpcs3/Gui/MainFrame.cpp | 2 +- rpcs3/stdafx.h | 4 ++++ 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index fc2c69f7e5..130ad04fde 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -298,31 +298,37 @@ void VFS::SaveLoadDevices(Array& res, bool is_load) { count = entries_count.LoadValue(count); +#ifdef _WIN32 +#define DL "\\" +#else +#define DL "/" +#endif + if(!count) { int idx; idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_hdd0/"; + res[idx].path = "$(EmulatorDir)" DL "dev_hdd0" DL; res[idx].mount = "/dev_hdd0/"; res[idx].device = vfsDevice_LocalFile; idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_hdd1/"; + res[idx].path = "$(EmulatorDir)" DL "dev_hdd1" DL; res[idx].mount = "/dev_hdd1/"; res[idx].device = vfsDevice_LocalFile; idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_flash/"; + res[idx].path = "$(EmulatorDir)" DL "dev_flash" DL; res[idx].mount = "/dev_flash/"; res[idx].device = vfsDevice_LocalFile; idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_usb000/"; + res[idx].path = "$(EmulatorDir)" DL "dev_usb000" DL; res[idx].mount = "/dev_usb000/"; res[idx].device = vfsDevice_LocalFile; idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_usb000/"; + res[idx].path = "$(EmulatorDir)" DL "dev_usb000" DL; res[idx].mount = "/dev_usb/"; res[idx].device = vfsDevice_LocalFile; @@ -332,7 +338,7 @@ void VFS::SaveLoadDevices(Array& res, bool is_load) res[idx].device = vfsDevice_LocalFile; idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)/../"; + res[idx].path = "$(GameDir)" DL ".." DL; res[idx].mount = "/dev_bdvd/"; res[idx].device = vfsDevice_LocalFile; diff --git a/rpcs3/Emu/FS/vfsDevice.cpp b/rpcs3/Emu/FS/vfsDevice.cpp index bc1014607b..d6af3341a7 100644 --- a/rpcs3/Emu/FS/vfsDevice.cpp +++ b/rpcs3/Emu/FS/vfsDevice.cpp @@ -48,8 +48,14 @@ u32 vfsDevice::CmpLocalPath(const wxString& local_path) wxFileName path0(m_local_path); path0.Normalize(); - wxArrayString arr0 = wxSplit(path0.GetFullPath(), '/'); - wxArrayString arr1 = wxSplit(local_path, '/'); +#ifdef _WIN32 +#define DL '\\' +#else +#define DL '/' +#endif + + wxArrayString arr0 = wxSplit(path0.GetFullPath(), DL); + wxArrayString arr1 = wxSplit(local_path, DL); const u32 lim = min(arr0.GetCount(), arr1.GetCount()); u32 ret = 0; @@ -179,7 +185,7 @@ wxString vfsDevice::GetWinPath(const wxString& p, bool is_dir) ret += p[i]; } - if(is_dir && ret[ret.Len() - 1] != '/') ret += '/'; + if(is_dir && ret[ret.Len() - 1] != '/' && ret[ret.Len() - 1] != '\\') ret += '/'; // ??? wxFileName res(ret); res.Normalize(); diff --git a/rpcs3/Emu/FS/vfsLocalFile.cpp b/rpcs3/Emu/FS/vfsLocalFile.cpp index ef953b4f49..8dedb87532 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.cpp +++ b/rpcs3/Emu/FS/vfsLocalFile.cpp @@ -56,7 +56,7 @@ bool vfsLocalFile::Create(const wxString& path) for(uint p=1; p < path.Len() && path[p] != '\0' ; p++) { for(; p < path.Len() && path[p] != '\0'; p++) - if(path[p] == '/') break; + if(path[p] == '/' || path[p] == '\\') break; // ??? if(p == path.Len() || path[p] == '\0') break; @@ -70,7 +70,8 @@ bool vfsLocalFile::Create(const wxString& path) } //create file - if(path(path.Len() - 1, 1) != '/' && !wxFileExists(path)) + wxString m = path(path.Len() - 1, 1); + if(m != '/' && m != '\\' && !wxFileExists(path)) // ??? { wxFile f; return f.Create(path); diff --git a/rpcs3/Emu/HDD/HDD.h b/rpcs3/Emu/HDD/HDD.h index 0535a018c0..3271ed4605 100644 --- a/rpcs3/Emu/HDD/HDD.h +++ b/rpcs3/Emu/HDD/HDD.h @@ -695,7 +695,7 @@ public: do { - if(s[pos] == '/' || s[pos] == '\0') + if(s[pos] == '\\' || s[pos] == '/' || s[pos] == '\0') // ??? { if(file_pos != -1) { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9e73da3995..7c92cb7e3d 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -141,7 +141,7 @@ void Emulator::Load() m_path = elf_path; } - ConLog.Write("Loading '%s'...", m_path.ToStdString().c_str()); + ConLog.Write("Loading '%s'...", m_path.wx_str()); GetInfo().Reset(); m_vfs.Init(m_path); @@ -149,7 +149,7 @@ void Emulator::Load() ConLog.Write("Mount info:"); for(uint i=0; i %s", m_vfs.m_devices[i].GetPs3Path().ToStdString().c_str(), m_vfs.m_devices[i].GetLocalPath().ToStdString().c_str()); + ConLog.Write("%s -> %s", m_vfs.m_devices[i].GetPs3Path().wx_str(), m_vfs.m_devices[i].GetLocalPath().wx_str()); } ConLog.SkipLn(); @@ -162,7 +162,7 @@ void Emulator::Load() if(!f.IsOpened()) { - ConLog.Error("Elf not found! (%s - %s)", m_path.ToStdString().c_str(), m_elf_path.ToStdString().c_str()); + ConLog.Error("Elf not found! (%s - %s)", m_path.wx_str(), m_elf_path.wx_str()); return; } @@ -441,7 +441,7 @@ void Emulator::LoadPoints(const std::string& path) if(version != bpdb_version || (sizeof(u16) + break_count * sizeof(u64) + sizeof(u32) + marked_count * sizeof(u64) + sizeof(u32)) != length) { - ConLog.Error("'%s' is broken", path.c_str()); + ConLog.Error("'%s' is broken", wxString(path).wx_str()); return; } diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index f66c4e89a8..269cfd0ce4 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -202,7 +202,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) } else { - ConLog.Error("Ps3 executable not found in selected folder (%s)", ctrl.GetPath().ToStdString().c_str()); + ConLog.Error("Ps3 executable not found in selected folder (%s)", ctrl.GetPath().wx_str()); } } diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 3a9515c24f..9e20712dd8 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -34,6 +34,10 @@ #include #endif +#ifndef _WIN32 +#define wx_str() ToStdString().c_str() +#endif + #include typedef unsigned int uint;