mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +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
|
|
@ -12,7 +12,7 @@ AudioDumper::~AudioDumper()
|
|||
|
||||
bool AudioDumper::Init(u8 ch)
|
||||
{
|
||||
if ((m_init = m_output.Open("audio.wav", rFile::write)))
|
||||
if ((m_init = m_output.open("audio.wav", o_write | o_create | o_trunc)))
|
||||
{
|
||||
m_header = WAVHeader(ch);
|
||||
WriteHeader();
|
||||
|
|
@ -25,7 +25,7 @@ void AudioDumper::WriteHeader()
|
|||
{
|
||||
if (m_init)
|
||||
{
|
||||
m_output.Write(&m_header, sizeof(m_header)); // write file header
|
||||
m_output.write(&m_header, sizeof(m_header)); // write file header
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ size_t AudioDumper::WriteData(const void* buffer, size_t size)
|
|||
if (m_init)
|
||||
#endif
|
||||
{
|
||||
size_t ret = m_output.Write(buffer, size);
|
||||
size_t ret = m_output.write(buffer, size);
|
||||
m_header.Size += (u32)ret;
|
||||
m_header.RIFF.Size += (u32)ret;
|
||||
return ret;
|
||||
|
|
@ -60,8 +60,8 @@ void AudioDumper::Finalize()
|
|||
{
|
||||
if (m_init)
|
||||
{
|
||||
m_output.Seek(0);
|
||||
m_output.Write(&m_header, sizeof(m_header)); // write fixed file header
|
||||
m_output.Close();
|
||||
m_output.seek(0);
|
||||
m_output.write(&m_header, sizeof(m_header)); // write fixed file header
|
||||
m_output.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ struct WAVHeader
|
|||
class AudioDumper
|
||||
{
|
||||
WAVHeader m_header;
|
||||
rFile m_output;
|
||||
rfile_t m_output;
|
||||
bool m_init;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ void VFS::UnMountAll()
|
|||
m_devices.clear();
|
||||
}
|
||||
|
||||
vfsFileBase* VFS::OpenFile(const std::string& ps3_path, vfsOpenMode mode) const
|
||||
vfsFileBase* VFS::OpenFile(const std::string& ps3_path, u32 mode) const
|
||||
{
|
||||
std::string path;
|
||||
|
||||
|
|
@ -165,23 +165,6 @@ vfsDirBase* VFS::OpenDir(const std::string& ps3_path) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool VFS::CreateFile(const std::string& ps3_path, bool overwrite) const
|
||||
{
|
||||
std::string path;
|
||||
|
||||
if (vfsDevice* dev = GetDevice(ps3_path, path))
|
||||
{
|
||||
std::unique_ptr<vfsFileBase> res(dev->GetNewFileStream());
|
||||
|
||||
if (res)
|
||||
{
|
||||
return res->Create(path, overwrite);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VFS::CreateDir(const std::string& ps3_path) const
|
||||
{
|
||||
std::string path;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
class vfsDevice;
|
||||
struct vfsFileBase;
|
||||
class vfsDirBase;
|
||||
enum vfsOpenMode : u8;
|
||||
|
||||
enum vfsDeviceType
|
||||
{
|
||||
|
|
@ -79,9 +78,8 @@ struct VFS
|
|||
|
||||
std::string GetLinked(const std::string& ps3_path) const;
|
||||
|
||||
vfsFileBase* OpenFile(const std::string& ps3_path, vfsOpenMode mode) const;
|
||||
vfsFileBase* OpenFile(const std::string& ps3_path, u32 mode) const;
|
||||
vfsDirBase* OpenDir(const std::string& ps3_path) const;
|
||||
bool CreateFile(const std::string& ps3_path, bool overwrite = false) const;
|
||||
bool CreateDir(const std::string& ps3_path) const;
|
||||
bool RemoveFile(const std::string& ps3_path) const;
|
||||
bool RemoveDir(const std::string& ps3_path) const;
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ vfsFile::vfsFile()
|
|||
{
|
||||
}
|
||||
|
||||
vfsFile::vfsFile(const std::string& path, vfsOpenMode mode)
|
||||
vfsFile::vfsFile(const std::string& path, u32 mode)
|
||||
: vfsFileBase(nullptr)
|
||||
, m_stream(nullptr)
|
||||
{
|
||||
Open(path, mode);
|
||||
}
|
||||
|
||||
bool vfsFile::Open(const std::string& path, vfsOpenMode mode)
|
||||
bool vfsFile::Open(const std::string& path, u32 mode)
|
||||
{
|
||||
Close();
|
||||
|
||||
|
|
@ -26,11 +26,6 @@ bool vfsFile::Open(const std::string& path, vfsOpenMode mode)
|
|||
return m_stream && m_stream->IsOpened();
|
||||
}
|
||||
|
||||
bool vfsFile::Create(const std::string& path, bool overwrite)
|
||||
{
|
||||
return m_stream->Create(path, overwrite);
|
||||
}
|
||||
|
||||
bool vfsFile::Exists(const std::string& path)
|
||||
{
|
||||
return m_stream->Exists(path);
|
||||
|
|
@ -52,7 +47,7 @@ bool vfsFile::Close()
|
|||
return vfsFileBase::Close();
|
||||
}
|
||||
|
||||
u64 vfsFile::GetSize()
|
||||
u64 vfsFile::GetSize() const
|
||||
{
|
||||
return m_stream->GetSize();
|
||||
}
|
||||
|
|
@ -67,7 +62,7 @@ u64 vfsFile::Read(void* dst, u64 size)
|
|||
return m_stream->Read(dst, size);
|
||||
}
|
||||
|
||||
u64 vfsFile::Seek(s64 offset, vfsSeekMode mode)
|
||||
u64 vfsFile::Seek(s64 offset, u32 mode)
|
||||
{
|
||||
return m_stream->Seek(offset, mode);
|
||||
}
|
||||
|
|
@ -79,5 +74,5 @@ u64 vfsFile::Tell() const
|
|||
|
||||
bool vfsFile::IsOpened() const
|
||||
{
|
||||
return m_stream && m_stream->IsOpened() && vfsFileBase::IsOpened();
|
||||
return m_stream && m_stream->IsOpened() /*&& vfsFileBase::IsOpened()*/;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,22 +8,21 @@ private:
|
|||
|
||||
public:
|
||||
vfsFile();
|
||||
vfsFile(const std::string& path, vfsOpenMode mode = vfsRead);
|
||||
vfsFile(const std::string& path, u32 mode = vfsRead);
|
||||
|
||||
virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead) override;
|
||||
virtual bool Create(const std::string& path, bool overwrite = false) override;
|
||||
virtual bool Open(const std::string& path, u32 mode = vfsRead) override;
|
||||
virtual bool Exists(const std::string& path) override;
|
||||
virtual bool Rename(const std::string& from, const std::string& to) override;
|
||||
virtual bool Remove(const std::string& path) override;
|
||||
virtual bool Close() override;
|
||||
|
||||
virtual u64 GetSize() override;
|
||||
virtual u64 GetSize() const override;
|
||||
|
||||
virtual u64 Write(const void* src, u64 size) override;
|
||||
virtual u64 Read(void* dst, u64 size) override;
|
||||
|
||||
virtual u64 Seek(s64 offset, vfsSeekMode mode = vfsSeekSet) override;
|
||||
virtual u64 Seek(s64 offset, u32 mode = from_begin) override;
|
||||
virtual u64 Tell() const override;
|
||||
|
||||
virtual bool IsOpened() const override;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,18 +12,11 @@ vfsFileBase::~vfsFileBase()
|
|||
Close();
|
||||
}
|
||||
|
||||
bool Access(const std::string& path, vfsOpenMode mode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool vfsFileBase::Open(const std::string& path, vfsOpenMode mode)
|
||||
bool vfsFileBase::Open(const std::string& path, u32 mode)
|
||||
{
|
||||
m_path = path;
|
||||
m_mode = mode;
|
||||
|
||||
vfsStream::Reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +32,7 @@ std::string vfsFileBase::GetPath() const
|
|||
return m_path;
|
||||
}
|
||||
|
||||
vfsOpenMode vfsFileBase::GetOpenMode() const
|
||||
u32 vfsFileBase::GetOpenMode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
#pragma once
|
||||
#include "vfsStream.h"
|
||||
|
||||
enum vfsOpenMode : u8
|
||||
enum vfsOpenMode : u32
|
||||
{
|
||||
vfsRead = 0x1,
|
||||
vfsWrite = 0x2,
|
||||
vfsExcl = 0x4,
|
||||
vfsAppend = 0x8,
|
||||
vfsReadWrite = vfsRead | vfsWrite,
|
||||
vfsWriteExcl = vfsWrite | vfsExcl,
|
||||
vfsWriteAppend = vfsWrite | vfsAppend,
|
||||
vfsRead = o_read,
|
||||
vfsReadWrite = o_read | o_write,
|
||||
vfsWriteNew = o_write | o_create | o_trunc,
|
||||
vfsWriteExcl = o_write | o_create | o_excl,
|
||||
};
|
||||
|
||||
class vfsDevice;
|
||||
|
|
@ -18,20 +15,19 @@ struct vfsFileBase : public vfsStream
|
|||
{
|
||||
protected:
|
||||
std::string m_path;
|
||||
vfsOpenMode m_mode;
|
||||
u32 m_mode;
|
||||
vfsDevice* m_device;
|
||||
|
||||
public:
|
||||
vfsFileBase(vfsDevice* device);
|
||||
virtual ~vfsFileBase();
|
||||
|
||||
virtual bool Open(const std::string& path, vfsOpenMode mode);
|
||||
virtual bool Open(const std::string& path, u32 mode);
|
||||
virtual bool Close() override;
|
||||
virtual bool Create(const std::string& path, bool overwrite = false) { return false; }
|
||||
virtual bool Exists(const std::string& path) { return false; }
|
||||
virtual bool Rename(const std::string& from, const std::string& to) { return false; }
|
||||
virtual bool Remove(const std::string& path) { return false; }
|
||||
|
||||
std::string GetPath() const;
|
||||
vfsOpenMode GetOpenMode() const;
|
||||
u32 GetOpenMode() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,29 +1,27 @@
|
|||
#pragma once
|
||||
#include "vfsFileBase.h"
|
||||
#include "Utilities/rFile.h"
|
||||
|
||||
class vfsLocalFile : public vfsFileBase
|
||||
{
|
||||
private:
|
||||
rFile m_file;
|
||||
rfile_t m_file;
|
||||
|
||||
public:
|
||||
vfsLocalFile(vfsDevice* device);
|
||||
|
||||
virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead) override;
|
||||
virtual bool Create(const std::string& path, bool overwrite = false) override;
|
||||
virtual bool Open(const std::string& path, u32 mode = vfsRead) override;
|
||||
virtual bool Close() override;
|
||||
virtual bool Exists(const std::string& path) override;
|
||||
virtual bool Rename(const std::string& from, const std::string& to) override;
|
||||
virtual bool Remove(const std::string& path) override;
|
||||
|
||||
virtual u64 GetSize() override;
|
||||
virtual u64 GetSize() const override;
|
||||
|
||||
virtual u64 Write(const void* src, u64 size) override;
|
||||
virtual u64 Read(void* dst, u64 size) override;
|
||||
|
||||
virtual u64 Seek(s64 offset, vfsSeekMode mode = vfsSeekSet) override;
|
||||
virtual u64 Seek(s64 offset, u32 mode = from_begin) override;
|
||||
virtual u64 Tell() const override;
|
||||
|
||||
virtual bool IsOpened() const override;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,80 +1,2 @@
|
|||
#include "stdafx.h"
|
||||
#include "vfsStream.h"
|
||||
|
||||
vfsStream::vfsStream()
|
||||
{
|
||||
}
|
||||
|
||||
vfsStream::~vfsStream()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void vfsStream::Reset()
|
||||
{
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
bool vfsStream::Close()
|
||||
{
|
||||
Reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u64 vfsStream::GetSize()
|
||||
{
|
||||
u64 last_pos = Tell();
|
||||
Seek(0, vfsSeekEnd);
|
||||
u64 size = Tell();
|
||||
Seek(last_pos, vfsSeekSet);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
u64 vfsStream::Write(const void* src, u64 size)
|
||||
{
|
||||
m_pos += size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
u64 vfsStream::Read(void* dst, u64 size)
|
||||
{
|
||||
m_pos += size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
u64 vfsStream::Seek(s64 offset, vfsSeekMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case vfsSeekSet:
|
||||
m_pos = offset;
|
||||
break;
|
||||
case vfsSeekCur:
|
||||
m_pos += offset;
|
||||
break;
|
||||
case vfsSeekEnd:
|
||||
m_pos = GetSize() + offset;
|
||||
break;
|
||||
}
|
||||
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
u64 vfsStream::Tell() const
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
bool vfsStream::Eof()
|
||||
{
|
||||
return Tell() >= GetSize();
|
||||
}
|
||||
|
||||
bool vfsStream::IsOpened() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,44 +1,44 @@
|
|||
#pragma once
|
||||
|
||||
enum vfsSeekMode
|
||||
{
|
||||
vfsSeekSet,
|
||||
vfsSeekCur,
|
||||
vfsSeekEnd,
|
||||
};
|
||||
#include "Utilities/rFile.h"
|
||||
|
||||
struct vfsStream
|
||||
{
|
||||
protected:
|
||||
u64 m_pos;
|
||||
vfsStream() = default;
|
||||
|
||||
public:
|
||||
vfsStream();
|
||||
|
||||
virtual ~vfsStream();
|
||||
|
||||
virtual void Reset();
|
||||
virtual bool Close();
|
||||
|
||||
virtual u64 GetSize();
|
||||
|
||||
virtual u64 Write(const void* src, u64 size);
|
||||
|
||||
template<typename T> __forceinline bool SWrite(const T& data, u64 size = sizeof(T))
|
||||
virtual ~vfsStream()
|
||||
{
|
||||
return Write(&data, size) == size;
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual u64 Read(void* dst, u64 size);
|
||||
|
||||
template<typename T> __forceinline bool SRead(T& data, u64 size = sizeof(T))
|
||||
virtual bool Close()
|
||||
{
|
||||
return Read(&data, size) == size;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual u64 Seek(s64 offset, vfsSeekMode mode = vfsSeekSet);
|
||||
virtual u64 Tell() const;
|
||||
virtual bool Eof();
|
||||
virtual u64 GetSize() const = 0;
|
||||
|
||||
virtual bool IsOpened() const;
|
||||
virtual u64 Write(const void* src, u64 count) = 0;
|
||||
|
||||
template<typename T> __forceinline bool SWrite(const T& data, u64 count = sizeof(T))
|
||||
{
|
||||
return Write(&data, count) == count;
|
||||
}
|
||||
|
||||
virtual u64 Read(void* dst, u64 count) = 0;
|
||||
|
||||
template<typename T> __forceinline bool SRead(T& data, u64 count = sizeof(T))
|
||||
{
|
||||
return Read(&data, count) == count;
|
||||
}
|
||||
|
||||
virtual u64 Seek(s64 offset, u32 mode = from_begin) = 0;
|
||||
|
||||
virtual u64 Tell() const = 0;
|
||||
|
||||
virtual bool Eof() const
|
||||
{
|
||||
return Tell() >= GetSize();
|
||||
}
|
||||
|
||||
virtual bool IsOpened() const = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,48 +2,28 @@
|
|||
#include "Emu/Memory/Memory.h"
|
||||
#include "vfsStreamMemory.h"
|
||||
|
||||
vfsStreamMemory::vfsStreamMemory() : vfsStream()
|
||||
u64 vfsStreamMemory::Write(const void* src, u64 count)
|
||||
{
|
||||
}
|
||||
|
||||
vfsStreamMemory::vfsStreamMemory(u32 addr, u32 size) : vfsStream()
|
||||
{
|
||||
Open(addr, size);
|
||||
}
|
||||
|
||||
void vfsStreamMemory::Open(u32 addr, u32 size)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_size = size ? size : 0x100000000ull - addr; // determine max possible size
|
||||
|
||||
vfsStream::Reset();
|
||||
}
|
||||
|
||||
u64 vfsStreamMemory::GetSize()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
u64 vfsStreamMemory::Write(const void* src, u64 size)
|
||||
{
|
||||
assert(Tell() < m_size);
|
||||
if (Tell() + size > m_size)
|
||||
assert(m_pos < m_size);
|
||||
if (m_pos + count > m_size)
|
||||
{
|
||||
size = m_size - Tell();
|
||||
count = m_size - m_pos;
|
||||
}
|
||||
|
||||
memcpy(vm::get_ptr<void>(vm::cast(m_addr + Tell())), src, size);
|
||||
return vfsStream::Write(src, size);
|
||||
memcpy(vm::get_ptr<void>(vm::cast(m_addr + m_pos)), src, count);
|
||||
m_pos += count;
|
||||
return count;
|
||||
}
|
||||
|
||||
u64 vfsStreamMemory::Read(void* dst, u64 size)
|
||||
u64 vfsStreamMemory::Read(void* dst, u64 count)
|
||||
{
|
||||
assert(Tell() < GetSize());
|
||||
if (Tell() + size > GetSize())
|
||||
assert(m_pos < m_size);
|
||||
if (m_pos + count > m_size)
|
||||
{
|
||||
size = GetSize() - Tell();
|
||||
count = m_size - m_pos;
|
||||
}
|
||||
|
||||
memcpy(dst, vm::get_ptr<void>(vm::cast(m_addr + Tell())), size);
|
||||
return vfsStream::Read(dst, size);
|
||||
memcpy(dst, vm::get_ptr<void>(vm::cast(m_addr + m_pos)), count);
|
||||
m_pos += count;
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,57 @@
|
|||
#pragma once
|
||||
#include "vfsStream.h"
|
||||
|
||||
struct vfsStreamMemory : public vfsStream
|
||||
class vfsStreamMemory : public vfsStream
|
||||
{
|
||||
u32 m_addr;
|
||||
u64 m_size;
|
||||
u64 m_pos = 0;
|
||||
u32 m_addr = 0;
|
||||
u64 m_size = 0;
|
||||
|
||||
public:
|
||||
vfsStreamMemory();
|
||||
vfsStreamMemory(u32 addr, u32 size = 0);
|
||||
vfsStreamMemory() = default;
|
||||
|
||||
void Open(u32 addr, u32 size = 0);
|
||||
vfsStreamMemory(u32 addr, u32 size = 0)
|
||||
{
|
||||
Open(addr, size);
|
||||
}
|
||||
|
||||
virtual u64 GetSize() override;
|
||||
void Open(u32 addr, u32 size = 0)
|
||||
{
|
||||
m_pos = 0;
|
||||
m_addr = addr;
|
||||
m_size = size ? size : 0x100000000ull - addr; // determine max possible size
|
||||
}
|
||||
|
||||
virtual u64 Write(const void* src, u64 size) override;
|
||||
virtual u64 Read(void* dst, u64 size) override;
|
||||
};
|
||||
virtual u64 GetSize() const override
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
virtual u64 Write(const void* src, u64 count) override;
|
||||
|
||||
virtual u64 Read(void* dst, u64 count) override;
|
||||
|
||||
virtual u64 Seek(s64 offset, u32 mode = from_begin) override
|
||||
{
|
||||
assert(mode < 3);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case from_begin: return m_pos = offset;
|
||||
case from_cur: return m_pos += offset;
|
||||
case from_end: return m_pos = m_size + offset;
|
||||
}
|
||||
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
virtual u64 Tell() const override
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
virtual bool IsOpened() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ void vfsHDDManager::CreateEntry(vfsHDD_Entry& entry)
|
|||
|
||||
void vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size)
|
||||
{
|
||||
rFile f(path, rFile::write);
|
||||
rfile_t f(path, o_write | o_create | o_trunc);
|
||||
|
||||
static const u64 cur_dir_block = 1;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ void vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size)
|
|||
hdr.version = g_hdd_version;
|
||||
hdr.block_count = (size + block_size) / block_size;
|
||||
hdr.block_size = block_size;
|
||||
f.Write(&hdr, sizeof(vfsHDD_Hdr));
|
||||
f.write(&hdr, sizeof(vfsHDD_Hdr));
|
||||
|
||||
{
|
||||
vfsHDD_Entry entry;
|
||||
|
|
@ -41,14 +41,14 @@ void vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size)
|
|||
entry.data_block = hdr.next_block;
|
||||
entry.next_block = 0;
|
||||
|
||||
f.Seek(cur_dir_block * hdr.block_size);
|
||||
f.Write(&entry, sizeof(vfsHDD_Entry));
|
||||
f.Write(".");
|
||||
f.seek(cur_dir_block * hdr.block_size);
|
||||
f.write(&entry, sizeof(vfsHDD_Entry));
|
||||
f.write(".", 1);
|
||||
}
|
||||
|
||||
u8 null = 0;
|
||||
f.Seek(hdr.block_count * hdr.block_size - sizeof(null));
|
||||
f.Write(&null, sizeof(null));
|
||||
f.seek(hdr.block_count * hdr.block_size - sizeof(null));
|
||||
f.write(&null, sizeof(null));
|
||||
}
|
||||
|
||||
void vfsHDDManager::Format()
|
||||
|
|
@ -599,7 +599,7 @@ bool vfsHDD::GetNextEntry(u64& block, vfsHDD_Entry& entry, std::string& name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vfsHDD::Open(const std::string& path, vfsOpenMode mode)
|
||||
bool vfsHDD::Open(const std::string& path, u32 mode)
|
||||
{
|
||||
const char* s = path.c_str();
|
||||
u64 from = 0;
|
||||
|
|
@ -737,47 +737,44 @@ bool vfsHDD::RemoveEntry(const std::string& name)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vfsHDD::Create(const std::string& path)
|
||||
u64 vfsHDD::Write(const void* src, u64 size)
|
||||
{
|
||||
return false;
|
||||
return m_file.Write(src, size); // ???
|
||||
}
|
||||
|
||||
u32 vfsHDD::Write(const void* src, u32 size)
|
||||
u64 vfsHDD::Read(void* dst, u64 size)
|
||||
{
|
||||
return vfsFileBase::Write(src, m_file.Write(src, size));
|
||||
return m_file.Read(dst, size); // ???
|
||||
}
|
||||
|
||||
u32 vfsHDD::Read(void* dst, u32 size)
|
||||
{
|
||||
return vfsFileBase::Read(dst, m_file.Read(dst, size));
|
||||
}
|
||||
|
||||
u64 vfsHDD::Seek(s64 offset, vfsSeekMode mode)
|
||||
u64 vfsHDD::Seek(s64 offset, u32 mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case vfsSeekCur:
|
||||
m_file.Seek(Tell() + offset);
|
||||
break;
|
||||
|
||||
case vfsSeekSet:
|
||||
m_file.Seek(offset);
|
||||
break;
|
||||
|
||||
case vfsSeekEnd:
|
||||
m_file.Seek(m_file.GetSize() + offset);
|
||||
break;
|
||||
case from_begin: return m_file.Seek(offset);
|
||||
case from_cur: return m_file.Seek(Tell() + offset);
|
||||
case from_end: return m_file.Seek(m_file.GetSize() + offset);
|
||||
}
|
||||
|
||||
return vfsFileBase::Seek(offset, mode);
|
||||
return m_file.Tell(); // ???
|
||||
}
|
||||
|
||||
bool vfsHDD::Eof()
|
||||
u64 vfsHDD::Tell() const
|
||||
{
|
||||
return m_file.Tell(); // ???
|
||||
}
|
||||
|
||||
bool vfsHDD::Eof() const
|
||||
{
|
||||
return m_file.Eof();
|
||||
}
|
||||
|
||||
u64 vfsHDD::GetSize()
|
||||
bool vfsHDD::IsOpened() const
|
||||
{
|
||||
return true; // ???
|
||||
}
|
||||
|
||||
u64 vfsHDD::GetSize() const
|
||||
{
|
||||
return m_file.GetSize();
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ enum vfsHDD_EntryType : u8
|
|||
struct vfsHDD_Entry : public vfsHDD_Block
|
||||
{
|
||||
u64 data_block;
|
||||
vfsOpenMode access;
|
||||
u32 access;
|
||||
vfsHDD_EntryType type;
|
||||
u64 size;
|
||||
u64 ctime;
|
||||
|
|
@ -109,6 +109,11 @@ public:
|
|||
|
||||
bool Seek(u64 pos);
|
||||
|
||||
u64 Tell() const
|
||||
{
|
||||
return m_cur_block * m_hdd_info.block_size + m_position; // ???
|
||||
}
|
||||
|
||||
void SaveInfo();
|
||||
|
||||
u64 Read(void* dst, u64 size);
|
||||
|
|
@ -177,7 +182,7 @@ public:
|
|||
|
||||
bool GetNextEntry(u64& block, vfsHDD_Entry& entry, std::string& name);
|
||||
|
||||
virtual bool Open(const std::string& path, vfsOpenMode mode = vfsRead);
|
||||
virtual bool Open(const std::string& path, u32 mode = vfsRead);
|
||||
|
||||
bool HasEntry(const std::string& name);
|
||||
|
||||
|
|
@ -187,15 +192,17 @@ public:
|
|||
|
||||
bool RemoveEntry(const std::string& name);
|
||||
|
||||
virtual bool Create(const std::string& path);
|
||||
virtual u64 Write(const void* src, u64 count) override;
|
||||
|
||||
virtual u32 Write(const void* src, u32 size);
|
||||
virtual u64 Read(void* dst, u64 count) override;
|
||||
|
||||
virtual u32 Read(void* dst, u32 size);
|
||||
virtual u64 Seek(s64 offset, u32 mode = from_begin) override;
|
||||
|
||||
virtual u64 Seek(s64 offset, vfsSeekMode mode = vfsSeekSet);
|
||||
virtual u64 Tell() const override;
|
||||
|
||||
virtual bool Eof();
|
||||
virtual bool Eof() const override;
|
||||
|
||||
virtual u64 GetSize();
|
||||
virtual bool IsOpened() const override;
|
||||
|
||||
virtual u64 GetSize() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -182,14 +182,13 @@ public:
|
|||
, m_arb_shader("")
|
||||
, m_dst_reg_name("")
|
||||
{
|
||||
rFile f(path);
|
||||
if (!f.IsOpened())
|
||||
rfile_t f(path);
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
m_buffer_size = f.Length();
|
||||
m_buffer_size = f.size();
|
||||
m_buffer = new u8[m_buffer_size];
|
||||
f.Read(m_buffer, m_buffer_size);
|
||||
f.Close();
|
||||
f.read(m_buffer, m_buffer_size);
|
||||
m_arb_shader += fmt::format("Loading... [%s]\n", path.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -315,16 +314,15 @@ public:
|
|||
{
|
||||
u32 ptr;
|
||||
{
|
||||
rFile f(m_path);
|
||||
rfile_t f(m_path);
|
||||
|
||||
if (!f.IsOpened())
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
size_t size = f.Length();
|
||||
size_t size = f.size();
|
||||
vm::ps3::init();
|
||||
ptr = vm::alloc(size);
|
||||
f.Read(vm::get_ptr(ptr), size);
|
||||
f.Close();
|
||||
f.read(vm::get_ptr(ptr), size);
|
||||
}
|
||||
|
||||
auto& vmprog = vm::get_ref<CgBinaryProgram>(ptr);
|
||||
|
|
|
|||
|
|
@ -580,10 +580,8 @@ void GLTexture::Save(RSXTexture& tex, const std::string& name)
|
|||
return;
|
||||
}
|
||||
|
||||
{
|
||||
rFile f(name + ".raw", rFile::write);
|
||||
f.Write(alldata, texPixelCount * 4);
|
||||
}
|
||||
rfile_t(name + ".raw", o_write | o_create | o_trunc).write(alldata, texPixelCount * 4);
|
||||
|
||||
u8* data = new u8[texPixelCount * 3];
|
||||
u8* alpha = new u8[texPixelCount];
|
||||
|
||||
|
|
@ -1136,8 +1134,7 @@ bool GLGSRender::LoadProgram()
|
|||
checkForGlError("m_fragment_prog.Compile");
|
||||
|
||||
// TODO: This shouldn't use current dir
|
||||
rFile f("./FragmentProgram.txt", rFile::write);
|
||||
f.Write(m_fragment_prog.shader);
|
||||
rfile_t("./FragmentProgram.txt", o_write | o_create | o_trunc).write(m_fragment_prog.shader.c_str(), m_fragment_prog.shader.size());
|
||||
}
|
||||
|
||||
if (m_vp_buf_num == -1)
|
||||
|
|
@ -1148,8 +1145,7 @@ bool GLGSRender::LoadProgram()
|
|||
checkForGlError("m_vertex_prog.Compile");
|
||||
|
||||
// TODO: This shouldn't use current dir
|
||||
rFile f("./VertexProgram.txt", rFile::write);
|
||||
f.Write(m_vertex_prog.shader);
|
||||
rfile_t("./VertexProgram.txt", o_write | o_create | o_trunc).write(m_vertex_prog.shader.c_str(), m_vertex_prog.shader.size());
|
||||
}
|
||||
|
||||
if (m_fp_buf_num != -1 && m_vp_buf_num != -1)
|
||||
|
|
|
|||
|
|
@ -756,17 +756,17 @@ bool sdata_check(u32 version, u32 flags, u64 filesizeInput, u64 filesizeTmp)
|
|||
int sdata_unpack(const std::string& packed_file, const std::string& unpacked_file)
|
||||
{
|
||||
std::shared_ptr<vfsFileBase> packed_stream(Emu.GetVFS().OpenFile(packed_file, vfsRead));
|
||||
std::shared_ptr<vfsFileBase> unpacked_stream(Emu.GetVFS().OpenFile(unpacked_file, vfsWrite));
|
||||
std::shared_ptr<vfsFileBase> unpacked_stream(Emu.GetVFS().OpenFile(unpacked_file, vfsWriteNew));
|
||||
|
||||
if (!packed_stream || !packed_stream->IsOpened())
|
||||
{
|
||||
cellFs.Error("'%s' not found! flags: 0x%02x", packed_file.c_str(), vfsRead);
|
||||
cellFs.Error("File '%s' not found!", packed_file.c_str());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
if (!unpacked_stream || !unpacked_stream->IsOpened())
|
||||
{
|
||||
cellFs.Error("'%s' couldn't be created! flags: 0x%02x", unpacked_file.c_str(), vfsWrite);
|
||||
cellFs.Error("File '%s' couldn't be created!", unpacked_file.c_str());
|
||||
return CELL_ENOENT;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ __noinline s32 savedata_op(
|
|||
{
|
||||
case CELL_SAVEDATA_FILEOP_READ:
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(filepath, vfsRead));
|
||||
file.reset(Emu.GetVFS().OpenFile(filepath, o_read));
|
||||
file->Seek(fileSet->fileOffset);
|
||||
fileGet->excSize = file->Read(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize));
|
||||
break;
|
||||
|
|
@ -578,8 +578,7 @@ __noinline s32 savedata_op(
|
|||
|
||||
case CELL_SAVEDATA_FILEOP_WRITE:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(filepath);
|
||||
file.reset(Emu.GetVFS().OpenFile(filepath, vfsReadWrite));
|
||||
file.reset(Emu.GetVFS().OpenFile(filepath, o_write | o_create));
|
||||
file->Seek(fileSet->fileOffset);
|
||||
fileGet->excSize = file->Write(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize));
|
||||
// TODO: truncate this fucked shit
|
||||
|
|
@ -595,8 +594,7 @@ __noinline s32 savedata_op(
|
|||
|
||||
case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(filepath);
|
||||
file.reset(Emu.GetVFS().OpenFile(filepath, vfsReadWrite));
|
||||
file.reset(Emu.GetVFS().OpenFile(filepath, o_write | o_create));
|
||||
file->Seek(fileSet->fileOffset);
|
||||
fileGet->excSize = file->Write(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize));
|
||||
break;
|
||||
|
|
@ -613,9 +611,7 @@ __noinline s32 savedata_op(
|
|||
// Write PARAM.SFO
|
||||
if (psf)
|
||||
{
|
||||
Emu.GetVFS().CreateFile(sfo_path, true);
|
||||
|
||||
vfsFile f(sfo_path, vfsWrite);
|
||||
vfsFile f(sfo_path, vfsWriteNew);
|
||||
psf.Save(f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, s32 mode,
|
|||
sys_fs.Warning("sys_fs_open(path=*0x%x, flags=%#o, fd=*0x%x, mode=%#o, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size);
|
||||
sys_fs.Warning("*** path = '%s'", path.get_ptr());
|
||||
|
||||
std::shared_ptr<vfsStream> file;
|
||||
|
||||
// TODO: other checks for path
|
||||
|
||||
if (Emu.GetVFS().ExistsDir(path.get_ptr()))
|
||||
|
|
@ -42,81 +40,54 @@ s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, s32 mode,
|
|||
return CELL_FS_EISDIR;
|
||||
}
|
||||
|
||||
switch (flags)
|
||||
u32 open_mode = 0;
|
||||
|
||||
switch (flags & CELL_FS_O_ACCMODE)
|
||||
{
|
||||
case CELL_FS_O_RDONLY:
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsRead));
|
||||
break;
|
||||
case CELL_FS_O_RDONLY: open_mode |= o_read; break;
|
||||
case CELL_FS_O_WRONLY: open_mode |= o_write; break;
|
||||
case CELL_FS_O_RDWR: open_mode |= o_read | o_write; break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY:
|
||||
case CELL_FS_O_RDWR:
|
||||
if (flags & CELL_FS_O_CREAT)
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT:
|
||||
case CELL_FS_O_RDWR | CELL_FS_O_CREAT:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr());
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
|
||||
break;
|
||||
open_mode |= o_create;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_APPEND:
|
||||
if (flags & CELL_FS_O_TRUNC)
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
|
||||
break;
|
||||
open_mode |= o_trunc;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_EXCL:
|
||||
case CELL_FS_O_RDWR | CELL_FS_O_CREAT | CELL_FS_O_EXCL: // ???
|
||||
if (flags & CELL_FS_O_EXCL)
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteExcl));
|
||||
|
||||
if ((!file || !file->IsOpened()) && Emu.GetVFS().ExistsFile(path.get_ptr()))
|
||||
if ((flags & CELL_FS_O_CREAT) && !(flags & CELL_FS_O_TRUNC))
|
||||
{
|
||||
return CELL_FS_EEXIST;
|
||||
open_mode |= o_excl;
|
||||
}
|
||||
else
|
||||
{
|
||||
open_mode = 0; // error
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_TRUNC:
|
||||
if (flags & ~(CELL_FS_O_ACCMODE | CELL_FS_O_CREAT | CELL_FS_O_TRUNC | CELL_FS_O_EXCL))
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWrite));
|
||||
break;
|
||||
open_mode = 0; // error
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_TRUNC:
|
||||
if ((flags & CELL_FS_O_ACCMODE) == CELL_FS_O_ACCMODE)
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr());
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWrite));
|
||||
break;
|
||||
open_mode = 0; // error
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_APPEND:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr());
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_RDWR | CELL_FS_O_CREAT | CELL_FS_O_TRUNC:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr(), true);
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (!open_mode)
|
||||
{
|
||||
sys_fs.Error("sys_fs_open(): invalid or unimplemented flags (%#o)", flags);
|
||||
return CELL_FS_EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<vfsStream> file(Emu.GetVFS().OpenFile(path.get_ptr(), open_mode));
|
||||
|
||||
if (!file || !file->IsOpened())
|
||||
{
|
||||
|
|
@ -468,15 +439,9 @@ s32 sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ptr<u64> pos)
|
|||
{
|
||||
sys_fs.Log("sys_fs_lseek(fd=0x%x, offset=0x%llx, whence=0x%x, pos=*0x%x)", fd, offset, whence, pos);
|
||||
|
||||
vfsSeekMode seek_mode;
|
||||
|
||||
switch (whence)
|
||||
if (whence >= 3)
|
||||
{
|
||||
case CELL_FS_SEEK_SET: seek_mode = vfsSeekSet; break;
|
||||
case CELL_FS_SEEK_CUR: seek_mode = vfsSeekCur; break;
|
||||
case CELL_FS_SEEK_END: seek_mode = vfsSeekEnd; break;
|
||||
default:
|
||||
sys_fs.Error("sys_fs_lseek(fd=0x%x): unknown seek whence (0x%x)", fd, whence);
|
||||
sys_fs.Error("sys_fs_lseek(fd=0x%x): unknown seek whence (%d)", fd, whence);
|
||||
return CELL_FS_EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -489,7 +454,7 @@ s32 sys_fs_lseek(u32 fd, s64 offset, s32 whence, vm::ptr<u64> pos)
|
|||
|
||||
std::lock_guard<std::mutex> lock(file->mutex);
|
||||
|
||||
*pos = file->file->Seek(offset, seek_mode);
|
||||
*pos = file->file->Seek(offset, whence);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
@ -544,7 +509,7 @@ s32 sys_fs_truncate(vm::ptr<const char> path, u64 size)
|
|||
|
||||
s32 sys_fs_ftruncate(u32 fd, u64 size)
|
||||
{
|
||||
sys_fs.Warning("sys_fs_ftruncate(fd=0x%x, size=0x%llx)", fd, size);
|
||||
sys_fs.Todo("sys_fs_ftruncate(fd=0x%x, size=0x%llx)", fd, size);
|
||||
|
||||
const auto file = Emu.GetIdManager().GetIDData<fs_file_t>(fd);
|
||||
|
||||
|
|
@ -555,22 +520,7 @@ s32 sys_fs_ftruncate(u32 fd, u64 size)
|
|||
|
||||
std::lock_guard<std::mutex> lock(file->mutex);
|
||||
|
||||
u64 initialSize = file->file->GetSize();
|
||||
|
||||
if (initialSize < size)
|
||||
{
|
||||
u64 last_pos = file->file->Tell();
|
||||
file->file->Seek(0, vfsSeekEnd);
|
||||
static const char nullbyte = 0;
|
||||
file->file->Seek(size - initialSize - 1, vfsSeekCur);
|
||||
file->file->Write(&nullbyte, sizeof(char));
|
||||
file->file->Seek(last_pos, vfsSeekSet);
|
||||
}
|
||||
|
||||
if (initialSize > size)
|
||||
{
|
||||
// (TODO)
|
||||
}
|
||||
// it's near
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,11 +146,12 @@ bool Emulator::BootGame(const std::string& path, bool direct)
|
|||
"/USRDIR/EBOOT.BIN",
|
||||
"/EBOOT.BIN"
|
||||
};
|
||||
|
||||
auto curpath = path;
|
||||
|
||||
if (direct)
|
||||
{
|
||||
if (rFile::Access(curpath, rFile::read))
|
||||
if (rfile_t(curpath))
|
||||
{
|
||||
SetPath(curpath);
|
||||
Load();
|
||||
|
|
@ -163,7 +164,7 @@ bool Emulator::BootGame(const std::string& path, bool direct)
|
|||
{
|
||||
curpath = path + elf_path[i];
|
||||
|
||||
if (rFile::Access(curpath, rFile::read))
|
||||
if (rfile_t(curpath))
|
||||
{
|
||||
SetPath(curpath);
|
||||
Load();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue