#include "stdafx.h" #include "vfsDevice.h" vfsDevice::vfsDevice(const wxString& ps3_path, const wxString& local_path) : m_ps3_path(ps3_path) , m_local_path(GetWinPath(local_path)) { } wxString vfsDevice::GetLocalPath() const { return m_local_path; } wxString vfsDevice::GetPs3Path() const { return m_ps3_path; } void vfsDevice::SetPath(const wxString& ps3_path, const wxString& local_path) { m_ps3_path = ps3_path; m_local_path = local_path; } u32 vfsDevice::CmpPs3Path(const wxString& ps3_path) { const u32 lim = min(m_ps3_path.Len(), ps3_path.Len()); u32 ret = 0; for(u32 i=0; i= 0; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { if(dir++ == end_dir_count) { to = i; break; } } } return path(from, to - from); } wxString vfsDevice::GetRoot(const wxString& path) { //return wxFileName(path, wxPATH_UNIX).GetPath(); if(path.IsEmpty()) return wxEmptyString; u32 first_dir = path.Len() - 1; for(int i = path.Len() - 1, dir = 0, li = path.Len() - 1; i >= 0 && dir < 2; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { switch(dir++) { case 0: first_dir = i; break; case 1: if(!path(i + 1, li - i).Cmp("USRDIR")) return path(0, i + 1); continue; } li = i - 1; } } return path(0, first_dir + 1); } wxString vfsDevice::GetRootPs3(const wxString& path) { if(path.IsEmpty()) return wxEmptyString; static const wxString& home = "/dev_hdd0/game/"; u32 last_dir = 0; u32 first_dir = path.Len() - 1; for(int i = path.Len() - 1, dir = 0; i >= 0; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { switch(dir++) { case 1: if(!!path(i + 1, last_dir - i - 1).Cmp("USRDIR")) return wxEmptyString; break; case 2: return GetPs3Path(home + path(i + 1, last_dir - i - 1)); } last_dir = i; } } return GetPs3Path(home + path(0, last_dir - 1)); } wxString vfsDevice::GetWinPath(const wxString& p, bool is_dir) { if(p.IsEmpty()) return wxEmptyString; wxString ret; bool is_ls = false; for(u32 i=0; i