mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
move module initialization into a module manager, still has some issues like stopping not working and debug crashing add #idef 0 to modules that aren't in the windows project don't double initialize and don't de-initialize for now, since many modules don't expect it and it leads to many errors remove duplicate module lists for empty modules and implemented ones, make Module non-copyable but movable add secondary project, no real use for it now add some memleak config to the emucore and add asmjit path to rpcs3 small rebase error fixed to get it to compile again add filters for emucore re-add the module manager and static file WIP commit, linker errors abound some more abstraction layer stuff fix the remaining linker errors, re-enable platform specific mouse, pad and keyboard handlers rebasing fix memset undefined and re() usage of se_t before declaration Add wxGUI define by default for cmake builds fix copy constructors of Datetime header fix copy constructors of other wx interface classes remove static declarations of global variables make wxGLCanvas constructor non-ambiguous even with wx2.8. compat mode, fix wrong std::exception constructor calls remove duplicate definition for FromUTF8 and ToUTF8 temp changes
118 lines
2.5 KiB
C++
118 lines
2.5 KiB
C++
#include "stdafx.h"
|
|
#include "Emu/ConLog.h"
|
|
#include "vfsLocalFile.h"
|
|
|
|
static const rFile::OpenMode vfs2wx_mode(vfsOpenMode mode)
|
|
{
|
|
switch(mode)
|
|
{
|
|
case vfsRead: return rFile::read;
|
|
case vfsWrite: return rFile::write;
|
|
case vfsReadWrite: return rFile::read_write;
|
|
case vfsWriteExcl: return rFile::write_excl;
|
|
case vfsWriteAppend: return rFile::write_append;
|
|
}
|
|
|
|
return rFile::read;
|
|
}
|
|
|
|
static const rSeekMode vfs2wx_seek(vfsSeekMode mode)
|
|
{
|
|
switch(mode)
|
|
{
|
|
case vfsSeekSet: return rFromStart;
|
|
case vfsSeekCur: return rFromCurrent;
|
|
case vfsSeekEnd: return rFromEnd;
|
|
}
|
|
|
|
return rFromStart;
|
|
}
|
|
|
|
vfsLocalFile::vfsLocalFile(vfsDevice* device) : vfsFileBase(device)
|
|
{
|
|
}
|
|
|
|
bool vfsLocalFile::Open(const std::string& path, vfsOpenMode mode)
|
|
{
|
|
Close();
|
|
|
|
// if(m_device)
|
|
// {
|
|
// if(!m_file.Access(fmt::FromUTF8(vfsDevice::GetWinPath(m_device->GetLocalPath(), path)), vfs2wx_mode(mode))) return false;
|
|
|
|
// return m_file.Open(fmt::FromUTF8(vfsDevice::GetWinPath(m_device->GetLocalPath(), path)), vfs2wx_mode(mode)) &&
|
|
// vfsFileBase::Open(fmt::FromUTF8(vfsDevice::GetPs3Path(m_device->GetPs3Path(), path)), mode);
|
|
// }
|
|
// else
|
|
// {
|
|
if(!m_file.Access(path, vfs2wx_mode(mode))) return false;
|
|
|
|
return m_file.Open(path, vfs2wx_mode(mode)) && vfsFileBase::Open(path, mode);
|
|
// }
|
|
}
|
|
|
|
bool vfsLocalFile::Create(const std::string& path)
|
|
{
|
|
ConLog.Warning("vfsLocalFile::Create('%s')", path.c_str());
|
|
for(uint p=1; p < path.length() && path[p] != '\0' ; p++)
|
|
{
|
|
for(; p < path.length() && path[p] != '\0'; p++)
|
|
if(path[p] == '/' || path[p] == '\\') break; // ???
|
|
|
|
if(p == path.length() || path[p] == '\0')
|
|
break;
|
|
|
|
const std::string& dir = path.substr(0, p);
|
|
if(!rDirExists(dir))
|
|
{
|
|
ConLog.Write("create dir: %s", dir.c_str());
|
|
rMkdir(dir);
|
|
}
|
|
}
|
|
|
|
//create file
|
|
const char m = path[path.length() - 1];
|
|
if(m != '/' && m != '\\' && !rFileExists(path)) // ???
|
|
{
|
|
rFile f;
|
|
return f.Create(path);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool vfsLocalFile::Close()
|
|
{
|
|
return m_file.Close() && vfsFileBase::Close();
|
|
}
|
|
|
|
u64 vfsLocalFile::GetSize()
|
|
{
|
|
return m_file.Length();
|
|
}
|
|
|
|
u64 vfsLocalFile::Write(const void* src, u64 size)
|
|
{
|
|
return m_file.Write(src, size);
|
|
}
|
|
|
|
u64 vfsLocalFile::Read(void* dst, u64 size)
|
|
{
|
|
return m_file.Read(dst, size);
|
|
}
|
|
|
|
u64 vfsLocalFile::Seek(s64 offset, vfsSeekMode mode)
|
|
{
|
|
return m_file.Seek(offset, vfs2wx_seek(mode));
|
|
}
|
|
|
|
u64 vfsLocalFile::Tell() const
|
|
{
|
|
return m_file.Tell();
|
|
}
|
|
|
|
bool vfsLocalFile::IsOpened() const
|
|
{
|
|
return m_file.IsOpened() && vfsFileBase::IsOpened();
|
|
}
|