2013-06-30 10:46:29 +02:00
|
|
|
#pragma once
|
2014-03-27 05:34:55 +01:00
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
#include "vfsDevice.h"
|
|
|
|
|
|
2013-08-03 11:40:03 +02:00
|
|
|
enum vfsDeviceType
|
|
|
|
|
{
|
|
|
|
|
vfsDevice_LocalFile,
|
|
|
|
|
vfsDevice_HDD,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char* vfsDeviceTypeNames[] =
|
|
|
|
|
{
|
|
|
|
|
"Local",
|
|
|
|
|
"HDD",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VFSManagerEntry
|
|
|
|
|
{
|
|
|
|
|
vfsDeviceType device;
|
2014-04-01 02:33:55 +02:00
|
|
|
std::string device_path;
|
|
|
|
|
std::string path;
|
|
|
|
|
std::string mount;
|
2013-08-03 11:40:03 +02:00
|
|
|
|
2014-01-07 21:11:02 +01:00
|
|
|
VFSManagerEntry()
|
|
|
|
|
: device(vfsDevice_LocalFile)
|
|
|
|
|
, device_path("")
|
|
|
|
|
, path("")
|
|
|
|
|
, mount("")
|
2013-08-03 11:40:03 +02:00
|
|
|
{
|
|
|
|
|
}
|
2014-03-27 05:34:55 +01:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
VFSManagerEntry(const vfsDeviceType& device, const std::string& path, const std::string& mount)
|
2014-03-27 05:34:55 +01:00
|
|
|
: device(device)
|
|
|
|
|
, device_path("")
|
|
|
|
|
, path(path)
|
|
|
|
|
, mount(mount)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
}
|
2013-08-03 11:40:03 +02:00
|
|
|
};
|
|
|
|
|
|
2013-06-30 10:46:29 +02:00
|
|
|
struct VFS
|
|
|
|
|
{
|
2014-04-15 16:12:15 +02:00
|
|
|
~VFS();
|
|
|
|
|
|
2014-04-14 10:55:43 +02:00
|
|
|
//TODO: find out where these are supposed to be deleted or just make it shared_ptr
|
|
|
|
|
//and also make GetDevice and GetDeviceLocal return shared_ptr then.
|
2014-04-15 16:12:15 +02:00
|
|
|
// A vfsDevice will be deleted when they're unmounted or the VFS struct is destroyed.
|
|
|
|
|
// This will cause problems if other code stores the pointer returned by GetDevice/GetDeviceLocal
|
|
|
|
|
// and tries to use it after the device is unmounted.
|
2014-04-10 00:54:32 +02:00
|
|
|
std::vector<vfsDevice *> m_devices;
|
2014-04-01 02:33:55 +02:00
|
|
|
void Mount(const std::string& ps3_path, const std::string& local_path, vfsDevice* device);
|
|
|
|
|
void UnMount(const std::string& ps3_path);
|
2013-08-03 11:40:03 +02:00
|
|
|
void UnMountAll();
|
2013-06-30 10:46:29 +02:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
vfsFileBase* OpenFile(const std::string& ps3_path, vfsOpenMode mode) const;
|
|
|
|
|
vfsDirBase* OpenDir(const std::string& ps3_path) const;
|
|
|
|
|
bool CreateFile(const std::string& ps3_path) 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;
|
|
|
|
|
bool ExistsFile(const std::string& ps3_path) const;
|
|
|
|
|
bool ExistsDir(const std::string& ps3_path) const;
|
|
|
|
|
bool RenameFile(const std::string& ps3_path_from, const std::string& ps3_path_to) const;
|
|
|
|
|
bool RenameDir(const std::string& ps3_path_from, const std::string& ps3_path_to) const;
|
2014-02-16 16:19:06 +01:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
vfsDevice* GetDevice(const std::string& ps3_path, std::string& path) const;
|
|
|
|
|
vfsDevice* GetDeviceLocal(const std::string& local_path, std::string& path) const;
|
2013-08-03 11:40:03 +02:00
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
void Init(const std::string& path);
|
2014-03-27 05:34:55 +01:00
|
|
|
void SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load);
|
2014-04-10 00:54:32 +02:00
|
|
|
};
|