Fixed cellFsOpen & cellFsOpendir

This commit is contained in:
DH 2014-02-16 17:37:32 +02:00
parent 321d323beb
commit bd8ff4ca11
12 changed files with 56 additions and 42 deletions

View File

@ -50,12 +50,12 @@ void VFS::UnMountAll()
}
}
std::shared_ptr<vfsFileBase> VFS::OpenFile(const wxString& ps3_path, vfsOpenMode mode) const
vfsFileBase* VFS::OpenFile(const wxString& ps3_path, vfsOpenMode mode) const
{
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsFileBase> res = dev->GetNewFileStream())
if(vfsFileBase* res = dev->GetNewFileStream())
{
res->Open(path, mode);
return res;
@ -65,13 +65,13 @@ std::shared_ptr<vfsFileBase> VFS::OpenFile(const wxString& ps3_path, vfsOpenMode
return nullptr;
}
std::shared_ptr<vfsDirBase> VFS::OpenDir(const wxString& ps3_path) const
vfsDirBase* VFS::OpenDir(const wxString& ps3_path) const
{
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsDirBase> res = dev->GetNewDirStream())
if(vfsDirBase* res = dev->GetNewDirStream())
{
res->Open(path);
return res;
@ -86,7 +86,9 @@ bool VFS::CreateFile(const wxString& ps3_path) const
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsFileBase> res = dev->GetNewFileStream())
std::shared_ptr<vfsFileBase> res(dev->GetNewFileStream());
if(res)
{
return res->Create(path);
}
@ -100,7 +102,9 @@ bool VFS::CreateDir(const wxString& ps3_path) const
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsDirBase> res = dev->GetNewDirStream())
std::shared_ptr<vfsDirBase> res(dev->GetNewDirStream());
if(res)
{
return res->Create(path);
}
@ -114,7 +118,9 @@ bool VFS::RemoveFile(const wxString& ps3_path) const
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsFileBase> res = dev->GetNewFileStream())
std::shared_ptr<vfsFileBase> res(dev->GetNewFileStream());
if(res)
{
return res->Remove(path);
}
@ -128,7 +134,9 @@ bool VFS::RemoveDir(const wxString& ps3_path) const
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsDirBase> res = dev->GetNewDirStream())
std::shared_ptr<vfsDirBase> res(dev->GetNewDirStream());
if(res)
{
return res->Remove(path);
}
@ -142,7 +150,9 @@ bool VFS::ExistsFile(const wxString& ps3_path) const
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsFileBase> res = dev->GetNewFileStream())
std::shared_ptr<vfsFileBase> res(dev->GetNewFileStream());
if(res)
{
return res->Exists(path);
}
@ -156,7 +166,9 @@ bool VFS::ExistsDir(const wxString& ps3_path) const
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path, path))
{
if(std::shared_ptr<vfsDirBase> res = dev->GetNewDirStream())
std::shared_ptr<vfsDirBase> res(dev->GetNewDirStream());
if(res)
{
return res->IsExists(path);
}
@ -170,7 +182,9 @@ bool VFS::RenameFile(const wxString& ps3_path_from, const wxString& ps3_path_to)
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path_from, path))
{
if(std::shared_ptr<vfsFileBase> res = dev->GetNewFileStream())
std::shared_ptr<vfsFileBase> res(dev->GetNewFileStream());
if(res)
{
return res->Rename(path, ps3_path_to);
}
@ -184,7 +198,9 @@ bool VFS::RenameDir(const wxString& ps3_path_from, const wxString& ps3_path_to)
wxString path;
if(vfsDevice* dev = GetDevice(ps3_path_from, path))
{
if(std::shared_ptr<vfsDirBase> res = dev->GetNewDirStream())
std::shared_ptr<vfsDirBase> res(dev->GetNewDirStream());
if(res)
{
return res->Rename(path, ps3_path_to);
}

View File

@ -36,8 +36,8 @@ struct VFS
void UnMount(const wxString& ps3_path);
void UnMountAll();
std::shared_ptr<vfsFileBase> OpenFile(const wxString& ps3_path, vfsOpenMode mode) const;
std::shared_ptr<vfsDirBase> OpenDir(const wxString& ps3_path) const;
vfsFileBase* OpenFile(const wxString& ps3_path, vfsOpenMode mode) const;
vfsDirBase* OpenDir(const wxString& ps3_path) const;
bool CreateFile(const wxString& ps3_path) const;
bool CreateDir(const wxString& ps3_path) const;
bool RemoveFile(const wxString& ps3_path) const;

View File

@ -12,8 +12,8 @@ public:
vfsDevice(const wxString& ps3_path, const wxString& local_path);
vfsDevice() {}
virtual std::shared_ptr<vfsFileBase> GetNewFileStream()=0;
virtual std::shared_ptr<vfsDirBase> GetNewDirStream()=0;
virtual vfsFileBase* GetNewFileStream()=0;
virtual vfsDirBase* GetNewDirStream()=0;
wxString GetLocalPath() const;
wxString GetPs3Path() const;

View File

@ -3,12 +3,12 @@
#include "vfsLocalFile.h"
#include "vfsLocalDir.h"
std::shared_ptr<vfsFileBase> vfsDeviceLocalFile::GetNewFileStream()
vfsFileBase* vfsDeviceLocalFile::GetNewFileStream()
{
return std::make_shared<vfsLocalFile>(this);
return new vfsLocalFile(this);
}
std::shared_ptr<vfsDirBase> vfsDeviceLocalFile::GetNewDirStream()
vfsDirBase* vfsDeviceLocalFile::GetNewDirStream()
{
return std::make_shared<vfsLocalDir>(this);
return new vfsLocalDir(this);
}

View File

@ -4,6 +4,6 @@
class vfsDeviceLocalFile : public vfsDevice
{
public:
virtual std::shared_ptr<vfsFileBase> GetNewFileStream() override;
virtual std::shared_ptr<vfsDirBase> GetNewDirStream() override;
virtual vfsFileBase* GetNewFileStream() override;
virtual vfsDirBase* GetNewDirStream() override;
};

View File

@ -18,7 +18,7 @@ bool vfsDir::Open(const wxString& path)
{
Close();
m_stream = Emu.GetVFS().OpenDir(path);
m_stream.reset(Emu.GetVFS().OpenDir(path));
return m_stream && m_stream->IsOpened();
}

View File

@ -18,7 +18,7 @@ bool vfsFile::Open(const wxString& path, vfsOpenMode mode)
{
Close();
m_stream = Emu.GetVFS().OpenFile(path, mode);
m_stream.reset(Emu.GetVFS().OpenFile(path, mode));
return m_stream && m_stream->IsOpened();
}

View File

@ -5,12 +5,12 @@ vfsDeviceHDD::vfsDeviceHDD(const std::string& hdd_path) : m_hdd_path(hdd_path)
{
}
std::shared_ptr<vfsFileBase> vfsDeviceHDD::GetNewFileStream()
vfsFileBase* vfsDeviceHDD::GetNewFileStream()
{
return std::make_shared<vfsHDD>(this, m_hdd_path);
return new vfsHDD(this, m_hdd_path);
}
std::shared_ptr<vfsDirBase> vfsDeviceHDD::GetNewDirStream()
vfsDirBase* vfsDeviceHDD::GetNewDirStream()
{
return nullptr;
}

View File

@ -416,8 +416,8 @@ class vfsDeviceHDD : public vfsDevice
public:
vfsDeviceHDD(const std::string& hdd_path);
virtual std::shared_ptr<vfsFileBase> GetNewFileStream() override;
virtual std::shared_ptr<vfsDirBase> GetNewDirStream() override;
virtual vfsFileBase* GetNewFileStream() override;
virtual vfsDirBase* GetNewDirStream() override;
};
class vfsHDD : public vfsFileBase

View File

@ -115,7 +115,8 @@ int sceNpTrophyCreateContext(mem32_t context, mem_ptr_t<SceNpCommunicationId> co
{
if (entry->flags & DirEntry_TypeDir)
{
auto f = Emu.GetVFS().OpenFile("/app_home/TROPDIR/" + entry->name + "/TROPHY.TRP", vfsRead);
std::shared_ptr<vfsFileBase> f(Emu.GetVFS().OpenFile("/app_home/TROPDIR/" + entry->name + "/TROPHY.TRP", vfsRead));
if (f && f->IsOpened())
{
sceNpTrophyInternalContext ctxt;

View File

@ -35,8 +35,8 @@ bool sdata_check(u32 version, u32 flags, u64 filesizeInput, u64 filesizeTmp)
int sdata_unpack(wxString packed_file, wxString unpacked_file)
{
auto packed_stream = Emu.GetVFS().OpenFile(packed_file, vfsRead);
auto unpacked_stream = Emu.GetVFS().OpenFile(unpacked_file, vfsWrite);
std::shared_ptr<vfsFileBase> packed_stream(Emu.GetVFS().OpenFile(packed_file, vfsRead));
std::shared_ptr<vfsFileBase> unpacked_stream(Emu.GetVFS().OpenFile(unpacked_file, vfsWrite));
if(!packed_stream || !packed_stream->IsOpened())
{
@ -126,9 +126,7 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
int ret = sdata_unpack(path, unpacked_path);
if (ret) return ret;
auto stream = Emu.GetVFS().OpenFile(unpacked_path, vfsRead);
fd = sys_fs.GetNewId(stream.get(), flags);
stream = nullptr;
fd = sys_fs.GetNewId(Emu.GetVFS().OpenFile(unpacked_path, vfsRead), flags);
return CELL_OK;
}

View File

@ -67,7 +67,7 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
return CELL_EINVAL;
}
auto stream = Emu.GetVFS().OpenFile(ppath, o_mode);
vfsFileBase* stream = Emu.GetVFS().OpenFile(ppath, o_mode);
if(!stream || !stream->IsOpened())
{
@ -75,8 +75,7 @@ int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
return CELL_ENOENT;
}
fd = sys_fs.GetNewId(stream.get(), flags);
stream = nullptr;
fd = sys_fs.GetNewId(stream, flags);
ConLog.Warning("*** cellFsOpen(path=\"%s\"): fd = %d", path.wx_str(), fd.GetValue());
return CELL_OK;
@ -142,14 +141,14 @@ int cellFsOpendir(u32 path_addr, mem32_t fd)
if(!Memory.IsGoodAddr(path_addr) || !fd.IsGood())
return CELL_EFAULT;
std::shared_ptr<vfsDirBase> dir = Emu.GetVFS().OpenDir(path);
if(!dir->IsOpened())
vfsDirBase* dir = Emu.GetVFS().OpenDir(path);
if(!dir || !dir->IsOpened())
{
delete dir;
return CELL_ENOENT;
}
fd = sys_fs.GetNewId(dir.get());
dir = nullptr;
fd = sys_fs.GetNewId(dir);
return CELL_OK;
}