In-progress work: refactoring PAL not to be instanced.
This removes a lot of useless passing around of the PAL object.
This commit is contained in:
@@ -15,18 +15,12 @@ using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
Device::Device(xe_pal_ref pal, const char* path) {
|
||||
pal_ = xe_pal_retain(pal);
|
||||
Device::Device(const char* path) {
|
||||
path_ = xestrdupa(path);
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
xe_free(path_);
|
||||
xe_pal_release(pal_);
|
||||
}
|
||||
|
||||
xe_pal_ref Device::pal() {
|
||||
return xe_pal_retain(pal_);
|
||||
}
|
||||
|
||||
const char* Device::path() {
|
||||
|
||||
@@ -23,16 +23,14 @@ namespace fs {
|
||||
|
||||
class Device {
|
||||
public:
|
||||
Device(xe_pal_ref pal, const char* path);
|
||||
Device(const char* path);
|
||||
virtual ~Device();
|
||||
|
||||
xe_pal_ref pal();
|
||||
const char* path();
|
||||
|
||||
virtual Entry* ResolvePath(const char* path) = 0;
|
||||
|
||||
protected:
|
||||
xe_pal_ref pal_;
|
||||
char* path_;
|
||||
};
|
||||
|
||||
|
||||
@@ -74,9 +74,8 @@ private:
|
||||
}
|
||||
|
||||
|
||||
DiscImageDevice::DiscImageDevice(xe_pal_ref pal, const char* path,
|
||||
const xechar_t* local_path) :
|
||||
Device(pal, path) {
|
||||
DiscImageDevice::DiscImageDevice(const char* path, const xechar_t* local_path) :
|
||||
Device(path) {
|
||||
local_path_ = xestrdup(local_path);
|
||||
mmap_ = NULL;
|
||||
gdfx_ = NULL;
|
||||
@@ -89,7 +88,7 @@ DiscImageDevice::~DiscImageDevice() {
|
||||
}
|
||||
|
||||
int DiscImageDevice::Init() {
|
||||
mmap_ = xe_mmap_open(pal_, kXEFileModeRead, local_path_, 0, 0);
|
||||
mmap_ = xe_mmap_open(kXEFileModeRead, local_path_, 0, 0);
|
||||
if (!mmap_) {
|
||||
XELOGE("Disc image could not be mapped");
|
||||
return 1;
|
||||
|
||||
@@ -26,7 +26,7 @@ class GDFX;
|
||||
|
||||
class DiscImageDevice : public Device {
|
||||
public:
|
||||
DiscImageDevice(xe_pal_ref pal, const char* path, const xechar_t* local_path);
|
||||
DiscImageDevice(const char* path, const xechar_t* local_path);
|
||||
virtual ~DiscImageDevice();
|
||||
|
||||
int Init();
|
||||
|
||||
@@ -46,10 +46,7 @@ public:
|
||||
|
||||
virtual MemoryMapping* CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length) {
|
||||
xe_pal_ref pal = device()->pal();
|
||||
xe_mmap_ref mmap = xe_mmap_open(pal, file_mode, local_path_,
|
||||
offset, length);
|
||||
xe_pal_release(pal);
|
||||
xe_mmap_ref mmap = xe_mmap_open(file_mode, local_path_, offset, length);
|
||||
if (!mmap) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -70,9 +67,9 @@ private:
|
||||
}
|
||||
|
||||
|
||||
LocalDirectoryDevice::LocalDirectoryDevice(xe_pal_ref pal, const char* path,
|
||||
LocalDirectoryDevice::LocalDirectoryDevice(const char* path,
|
||||
const xechar_t* local_path) :
|
||||
Device(pal, path) {
|
||||
Device(path) {
|
||||
local_path_ = xestrdup(local_path);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace fs {
|
||||
|
||||
class LocalDirectoryDevice : public Device {
|
||||
public:
|
||||
LocalDirectoryDevice(xe_pal_ref pal, const char* path,
|
||||
const xechar_t* local_path);
|
||||
LocalDirectoryDevice(const char* path, const xechar_t* local_path);
|
||||
virtual ~LocalDirectoryDevice();
|
||||
|
||||
virtual Entry* ResolvePath(const char* path);
|
||||
|
||||
@@ -18,8 +18,7 @@ using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
FileSystem::FileSystem(xe_pal_ref pal) {
|
||||
pal_ = xe_pal_retain(pal);
|
||||
FileSystem::FileSystem() {
|
||||
}
|
||||
|
||||
FileSystem::~FileSystem() {
|
||||
@@ -31,8 +30,6 @@ FileSystem::~FileSystem() {
|
||||
}
|
||||
devices_.clear();
|
||||
symlinks_.clear();
|
||||
|
||||
xe_pal_release(pal_);
|
||||
}
|
||||
|
||||
int FileSystem::RegisterDevice(const char* path, Device* device) {
|
||||
@@ -42,13 +39,13 @@ int FileSystem::RegisterDevice(const char* path, Device* device) {
|
||||
|
||||
int FileSystem::RegisterLocalDirectoryDevice(
|
||||
const char* path, const xechar_t* local_path) {
|
||||
Device* device = new LocalDirectoryDevice(pal_, path, local_path);
|
||||
Device* device = new LocalDirectoryDevice(path, local_path);
|
||||
return RegisterDevice(path, device);
|
||||
}
|
||||
|
||||
int FileSystem::RegisterDiscImageDevice(
|
||||
const char* path, const xechar_t* local_path) {
|
||||
DiscImageDevice* device = new DiscImageDevice(pal_, path, local_path);
|
||||
DiscImageDevice* device = new DiscImageDevice(path, local_path);
|
||||
if (device->Init()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class Device;
|
||||
|
||||
class FileSystem {
|
||||
public:
|
||||
FileSystem(xe_pal_ref pal);
|
||||
FileSystem();
|
||||
~FileSystem();
|
||||
|
||||
int RegisterDevice(const char* path, Device* device);
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
Entry* ResolvePath(const char* path);
|
||||
|
||||
private:
|
||||
xe_pal_ref pal_;
|
||||
std::vector<Device*> devices_;
|
||||
std::tr1::unordered_map<std::string, std::string> symlinks_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user