diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 9aa2b2b47f..86821274ad 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -1,5 +1,9 @@ #include "stdafx.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") +#pragma warning(disable : 4996) #include +#pragma warning(pop) std::string u128::to_hex() const { diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index 2dd000b319..f4b323a737 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -1,8 +1,10 @@ #include "stdafx.h" #include "Log.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") #pragma warning(disable : 4996) #include -#include +#pragma warning(pop) #include "rFile.h" #ifdef _WIN32 @@ -662,49 +664,3 @@ bool rDir::GetNext(std::string *filename) const *filename = str.ToStdString(); return res; } - -rFileName::rFileName() -{ - handle = reinterpret_cast(new wxFileName()); -} - -rFileName::~rFileName() -{ - delete reinterpret_cast(handle); -} - -rFileName::rFileName(const rFileName& filename) -{ - handle = reinterpret_cast(new wxFileName(*reinterpret_cast(filename.handle))); -} - - -rFileName::rFileName(const std::string& name) -{ - handle = reinterpret_cast(new wxFileName(fmt::FromUTF8(name))); -} - -std::string rFileName::GetFullPath() -{ - return fmt::ToUTF8(reinterpret_cast(handle)->GetFullPath()); -} - -std::string rFileName::GetPath() -{ - return fmt::ToUTF8(reinterpret_cast(handle)->GetPath()); -} - -std::string rFileName::GetName() -{ - return fmt::ToUTF8(reinterpret_cast(handle)->GetName()); -} - -std::string rFileName::GetFullName() -{ - return fmt::ToUTF8(reinterpret_cast(handle)->GetFullName()); -} - -bool rFileName::Normalize() -{ - return reinterpret_cast(handle)->Normalize(); -} diff --git a/Utilities/rFile.h b/Utilities/rFile.h index 93bb522053..bd7ca945c0 100644 --- a/Utilities/rFile.h +++ b/Utilities/rFile.h @@ -44,16 +44,12 @@ struct rfile_t final #ifdef _WIN32 using handle_type = void*; #else - using handle_type = int; + using handle_type = intptr_t; #endif private: handle_type fd; -#ifndef _WIN32 - handle_type pad; -#endif - public: rfile_t(); ~rfile_t(); @@ -95,17 +91,3 @@ struct rDir void *handle; }; -struct rFileName -{ - rFileName(); - rFileName(const rFileName& other); - ~rFileName(); - rFileName(const std::string& name); - std::string GetFullPath(); - std::string GetPath(); - std::string GetName(); - std::string GetFullName(); - bool Normalize(); - - void *handle; -}; diff --git a/Utilities/rMsgBox.cpp b/Utilities/rMsgBox.cpp index cf4c027096..152ac74b94 100644 --- a/Utilities/rMsgBox.cpp +++ b/Utilities/rMsgBox.cpp @@ -1,7 +1,10 @@ #include "stdafx.h" #include "restore_new.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") #pragma warning(disable : 4996) #include +#pragma warning(pop) #include "define_new_memleakdetect.h" #include "rMsgBox.h" diff --git a/Utilities/rPlatform.cpp b/Utilities/rPlatform.cpp index 57a32e1425..63eae5d141 100644 --- a/Utilities/rPlatform.cpp +++ b/Utilities/rPlatform.cpp @@ -1,7 +1,10 @@ #include "stdafx.h" #include "restore_new.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") #pragma warning(disable : 4996) #include +#pragma warning(pop) #include "define_new_memleakdetect.h" #ifndef _WIN32 diff --git a/Utilities/rTime.cpp b/Utilities/rTime.cpp index 194394317c..58f607d1e3 100644 --- a/Utilities/rTime.cpp +++ b/Utilities/rTime.cpp @@ -1,7 +1,10 @@ #include "stdafx.h" #include "rTime.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") #pragma warning(disable : 4996) #include +#pragma warning(pop) std::string rDefaultDateTimeFormat = "%c"; diff --git a/Utilities/rXml.cpp b/Utilities/rXml.cpp index 7d2ed9a533..30e0b457c2 100644 --- a/Utilities/rXml.cpp +++ b/Utilities/rXml.cpp @@ -1,6 +1,10 @@ #include "stdafx.h" #include "Utilities/rXml.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") +#pragma warning(disable : 4996) #include +#pragma warning(pop) rXmlNode::rXmlNode() { diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index 9386c13581..0a7b377737 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -1,17 +1,19 @@ #include "stdafx.h" +#include "Utilities/Log.h" +#include "Utilities/rFile.h" #include "utils.h" #include "aes.h" #include "sha1.h" #include "key_vault.h" #include "unpkg.h" #include "restore_new.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependency: ") #pragma warning(disable : 4996) #include +#pragma warning(pop) #include "define_new_memleakdetect.h" -#include "Utilities/Log.h" -#include "Utilities/rFile.h" - // Decryption. bool CheckHeader(const rfile_t& pkg_f, PKGHeader* m_header) { diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 1ad55c49bc..198eaf8546 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -6,9 +6,12 @@ #include "utils.h" #include "Emu/FS/vfsLocalFile.h" #include "unself.h" +#pragma warning(push) +#pragma message("TODO: remove wx dependencies: ") #pragma warning(disable : 4996) #include #include +#pragma warning(pop) __forceinline u8 Read8(vfsStream& f) { diff --git a/rpcs3/Emu/FS/vfsDevice.cpp b/rpcs3/Emu/FS/vfsDevice.cpp index 1349939987..652c6f4f55 100644 --- a/rpcs3/Emu/FS/vfsDevice.cpp +++ b/rpcs3/Emu/FS/vfsDevice.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "vfsDevice.h" -#include "Utilities/rFile.h" vfsDevice::vfsDevice(const std::string& ps3_path, const std::string& local_path) : m_ps3_path(ps3_path) @@ -46,16 +45,13 @@ u32 vfsDevice::CmpLocalPath(const std::string& local_path) if(local_path.length() < m_local_path.length()) return 0; - rFileName path0(m_local_path); - path0.Normalize(); - #ifdef _WIN32 #define DL "\\" #else #define DL "/" #endif - std::vector arr0 = fmt::rSplit(path0.GetFullPath(), DL); + std::vector arr0 = fmt::rSplit(m_local_path, DL); std::vector arr1 = fmt::rSplit(local_path, DL); const u32 lim = (u32)std::min(arr0.size(), arr1.size()); @@ -188,9 +184,7 @@ std::string vfsDevice::GetWinPath(const std::string& p, bool is_dir) if(is_dir && ret[ret.length() - 1] != '/' && ret[ret.length() - 1] != '\\') ret += '/'; // ??? - rFileName res(ret); - res.Normalize(); - return res.GetFullPath(); + return ret; } std::string vfsDevice::GetWinPath(const std::string& l, const std::string& r) diff --git a/rpcs3/Emu/FS/vfsFile.cpp b/rpcs3/Emu/FS/vfsFile.cpp index 415167ebdc..649a03fcda 100644 --- a/rpcs3/Emu/FS/vfsFile.cpp +++ b/rpcs3/Emu/FS/vfsFile.cpp @@ -44,7 +44,8 @@ bool vfsFile::Remove(const std::string& path) bool vfsFile::Close() { m_stream.reset(); - return vfsFileBase::Close(); + + return true; } u64 vfsFile::GetSize() const @@ -74,5 +75,5 @@ u64 vfsFile::Tell() const bool vfsFile::IsOpened() const { - return m_stream && m_stream->IsOpened() /*&& vfsFileBase::IsOpened()*/; + return m_stream && m_stream->IsOpened(); } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index f6dbac5d38..fe2f9edc80 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -32,7 +32,6 @@ #include "Loader/ELF32.h" #include "../Crypto/unself.h" -#include #include using namespace PPU_instr; @@ -184,28 +183,44 @@ void Emulator::Load() if (!rIsFile(m_path)) return; + const std::string elf_dir = m_path.substr(0, m_path.find_last_of("/\\", std::string::npos, 2) + 1); + if (IsSelf(m_path)) { - std::string elf_path = rFileName(m_path).GetPath(); + const std::string full_name = m_path.substr(elf_dir.length()); - if (fmt::CmpNoCase(rFileName(m_path).GetFullName(),"EBOOT.BIN") == 0) + const std::string base_name = full_name.substr(0, full_name.find_last_of('.', std::string::npos)); + + const std::string ext = full_name.substr(base_name.length()); + + if (fmt::toupper(full_name) == "EBOOT.BIN") { - elf_path += "/BOOT.BIN"; + m_path = elf_dir + "BOOT.BIN"; + } + else if (fmt::toupper(ext) == ".SELF") + { + m_path = elf_dir + base_name + ".elf"; + } + else if (fmt::toupper(ext) == ".SPRX") + { + m_path = elf_dir + base_name + ".prx"; } else { - elf_path += "/" + rFileName(m_path).GetName() + ".elf"; + m_path = elf_dir + base_name + ".decrypted" + ext; } - if (!DecryptSelf(elf_path, m_path)) - return; + LOG_NOTICE(LOADER, "Decrypting '%s%s'...", elf_dir, full_name); - m_path = elf_path; + if (!DecryptSelf(m_path, elf_dir + full_name)) + { + return; + } } LOG_NOTICE(LOADER, "Loading '%s'...", m_path.c_str()); GetInfo().Reset(); - GetVFS().Init(rFileName(m_path).GetPath()); + GetVFS().Init(elf_dir); LOG_NOTICE(LOADER, " "); //used to be skip_line LOG_NOTICE(LOADER, "Mount info:"); @@ -242,13 +257,14 @@ void Emulator::Load() if (m_elf_path.empty()) { GetVFS().GetDeviceLocal(m_path, m_elf_path); + LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path); } f.Open(m_elf_path); if (!f.IsOpened()) { - LOG_ERROR(LOADER, "Elf not found! (%s - %s)", m_path.c_str(), m_elf_path.c_str()); + LOG_ERROR(LOADER, "Opening '%s' failed", m_path.c_str()); return; }