#include "stdafx.h" #include #include "vfsDevice.h" vfsDevice::vfsDevice(const std::string& ps3_path, const std::string& local_path) : m_ps3_path(ps3_path) , m_local_path(GetWinPath(local_path)) { } std::string vfsDevice::GetLocalPath() const { return m_local_path; } std::string vfsDevice::GetPs3Path() const { return m_ps3_path; } void vfsDevice::SetPath(const std::string& ps3_path, const std::string& local_path) { m_ps3_path = ps3_path; m_local_path = local_path; } u32 vfsDevice::CmpPs3Path(const std::string& ps3_path) { const u32 lim = std::min(m_ps3_path.length(), ps3_path.length()); u32 ret = 0; for(u32 i=0; i arr0 = fmt::rSplit(path0.GetFullPath(), DL); std::vector arr1 = fmt::rSplit(local_path, DL); const u32 lim = std::min(arr0.size(), arr1.size()); 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.substr(from, to - from); } std::string vfsDevice::GetRoot(const std::string& path) { //return fmt::ToUTF8(wxFileName(fmt::FromUTF8(path), wxPATH_UNIX).GetPath()); if(path.empty()) return ""; u32 first_dir = path.length() - 1; for(int i = path.length() - 1, dir = 0, li = path.length() - 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.substr(i + 1, li - i).compare("USRDIR")) return path.substr(0, i + 1); continue; } li = i - 1; } } return path.substr(0, first_dir + 1); } std::string vfsDevice::GetRootPs3(const std::string& path) { if(path.empty()) return ""; static const std::string home = "/dev_hdd0/game/"; u32 last_dir = 0; u32 first_dir = path.length() - 1; for(int i = path.length() - 1, dir = 0; i >= 0; --i) { if(path[i] == '\\' || path[i] == '/' || i == 0) { switch(dir++) { case 1: if(path.substr(i + 1, last_dir - i - 1) == "USRDIR") return ""; break; case 2: return GetPs3Path(home + path.substr(i + 1, last_dir - i - 1)); } last_dir = i; } } return GetPs3Path(home + path.substr(0, last_dir - 1)); } std::string vfsDevice::GetWinPath(const std::string& p, bool is_dir) { if(p.empty()) return ""; std::string ret; bool is_ls = false; for(u32 i=0; i