mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 14:37:08 +00:00
wxFile removed (rFile -> rfile_t)
This commit is contained in:
parent
2cafa84b75
commit
ab405901ee
43 changed files with 814 additions and 973 deletions
|
|
@ -2,123 +2,50 @@
|
|||
#include "Utilities/Log.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)
|
||||
bool vfsLocalFile::Open(const std::string& path, u32 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, bool overwrite)
|
||||
{
|
||||
LOG_WARNING(HLE, "vfsLocalFile::Create('%s', overwrite=%d)", path.c_str(), overwrite);
|
||||
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(!rExists(dir))
|
||||
{
|
||||
LOG_NOTICE(HLE, "create dir: %s", dir.c_str());
|
||||
rMkdir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
//create file
|
||||
const char m = path[path.length() - 1];
|
||||
if(m != '/' && m != '\\' && !rExists(path)) // ???
|
||||
{
|
||||
rFile f;
|
||||
if (!f.Create(path, overwrite)) {
|
||||
if (overwrite) LOG_NOTICE(HLE, "vfsLocalFile::Create: couldn't create file");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return m_file.open(path, mode) && vfsFileBase::Open(path, mode);
|
||||
}
|
||||
|
||||
bool vfsLocalFile::Close()
|
||||
{
|
||||
return m_file.Close() && vfsFileBase::Close();
|
||||
return m_file.close() && vfsFileBase::Close();
|
||||
}
|
||||
|
||||
u64 vfsLocalFile::GetSize()
|
||||
u64 vfsLocalFile::GetSize() const
|
||||
{
|
||||
return m_file.Length();
|
||||
return m_file.size();
|
||||
}
|
||||
|
||||
u64 vfsLocalFile::Write(const void* src, u64 size)
|
||||
{
|
||||
return m_file.Write(src, size);
|
||||
return m_file.write(src, size);
|
||||
}
|
||||
|
||||
u64 vfsLocalFile::Read(void* dst, u64 size)
|
||||
{
|
||||
return m_file.Read(dst, size);
|
||||
return m_file.read(dst, size);
|
||||
}
|
||||
|
||||
u64 vfsLocalFile::Seek(s64 offset, vfsSeekMode mode)
|
||||
u64 vfsLocalFile::Seek(s64 offset, u32 mode)
|
||||
{
|
||||
return m_file.Seek(offset, vfs2wx_seek(mode));
|
||||
return m_file.seek(offset, mode);
|
||||
}
|
||||
|
||||
u64 vfsLocalFile::Tell() const
|
||||
{
|
||||
return m_file.Tell();
|
||||
return m_file.seek(0, from_cur);
|
||||
}
|
||||
|
||||
bool vfsLocalFile::IsOpened() const
|
||||
{
|
||||
return m_file.IsOpened() && vfsFileBase::IsOpened();
|
||||
return m_file /*&& vfsFileBase::IsOpened()*/;
|
||||
}
|
||||
|
||||
bool vfsLocalFile::Exists(const std::string& path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue