Fix slashes for Windows :p

This commit is contained in:
Nekotekina 2014-03-21 13:45:26 +04:00
parent cad7a05848
commit 39d1e21802
7 changed files with 34 additions and 17 deletions

View file

@ -298,31 +298,37 @@ void VFS::SaveLoadDevices(Array<VFSManagerEntry>& 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<VFSManagerEntry>& 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;

View file

@ -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();

View file

@ -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);

View file

@ -695,7 +695,7 @@ public:
do
{
if(s[pos] == '/' || s[pos] == '\0')
if(s[pos] == '\\' || s[pos] == '/' || s[pos] == '\0') // ???
{
if(file_pos != -1)
{

View file

@ -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<m_vfs.m_devices.GetCount(); ++i)
{
ConLog.Write("%s -> %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;
}

View file

@ -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());
}
}

View file

@ -34,6 +34,10 @@
#include <wx/wxprec.h>
#endif
#ifndef _WIN32
#define wx_str() ToStdString().c_str()
#endif
#include <cstdint>
typedef unsigned int uint;