Skeleton for the virtual filesystem.
This commit is contained in:
parent
c77bcbf879
commit
59189f12ab
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_FS_DEVICE_H_
|
||||
#define XENIA_KERNEL_FS_DEVICE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class Device {
|
||||
public:
|
||||
Device(xe_pal_ref pal);
|
||||
virtual ~Device();
|
||||
|
||||
virtual Entry* ResolvePath(const char* path) = 0;
|
||||
|
||||
protected:
|
||||
xe_pal_ref pal_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_FS_DEVICE_H_
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_FS_ENTRY_H_
|
||||
#define XENIA_KERNEL_FS_ENTRY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class Device;
|
||||
|
||||
|
||||
class Entry {
|
||||
public:
|
||||
enum Type {
|
||||
kTypeFile,
|
||||
kTypeDirectory,
|
||||
};
|
||||
|
||||
Entry(Type type, Device* device, const char* path);
|
||||
virtual ~Entry();
|
||||
|
||||
Type type();
|
||||
Device* device();
|
||||
const char* path();
|
||||
const char* name();
|
||||
|
||||
private:
|
||||
Type type_;
|
||||
Device* device_;
|
||||
char* path_;
|
||||
char* name_;
|
||||
};
|
||||
|
||||
|
||||
class FileEntry : public Entry {
|
||||
public:
|
||||
FileEntry(Device* device, const char* path);
|
||||
virtual ~FileEntry();
|
||||
|
||||
//virtual void Query();
|
||||
};
|
||||
|
||||
|
||||
class DirectoryEntry : public Entry {
|
||||
public:
|
||||
DirectoryEntry(Device* device, const char* path);
|
||||
virtual ~DirectoryEntry();
|
||||
|
||||
//virtual void Query();
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_FS_ENTRY_H_
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_FS_FILESYSTEM_H_
|
||||
#define XENIA_KERNEL_FS_FILESYSTEM_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class Device;
|
||||
|
||||
|
||||
class FileSystem {
|
||||
public:
|
||||
FileSystem(xe_pal_ref pal);
|
||||
~FileSystem();
|
||||
|
||||
int RegisterDevice(const char* path, Device* device);
|
||||
int RegisterLocalDirectoryDevice(const char* path,
|
||||
const xechar_t* local_path);
|
||||
int RegisterDiscImageDevice(const char* path, const xechar_t* local_path);
|
||||
|
||||
int CreateSymbolicLink(const char* path, const char* target);
|
||||
int DeleteSymbolicLink(const char* path);
|
||||
|
||||
Entry* ResolvePath(const char* path);
|
||||
|
||||
private:
|
||||
xe_pal_ref pal_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_FS_FILESYSTEM_H_
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/xex2.h>
|
||||
#include <xenia/kernel/fs/filesystem.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
|
@ -45,20 +46,24 @@ public:
|
|||
const xechar_t* command_line);
|
||||
~Runtime();
|
||||
|
||||
const xechar_t* command_line();
|
||||
|
||||
xe_pal_ref pal();
|
||||
xe_memory_ref memory();
|
||||
shared_ptr<cpu::Processor> processor();
|
||||
shared_ptr<ExportResolver> export_resolver();
|
||||
const xechar_t* command_line();
|
||||
shared_ptr<fs::FileSystem> filesystem();
|
||||
|
||||
int LaunchModule(const xechar_t* path);
|
||||
|
||||
private:
|
||||
xechar_t command_line_[2048];
|
||||
|
||||
xe_pal_ref pal_;
|
||||
xe_memory_ref memory_;
|
||||
shared_ptr<cpu::Processor> processor_;
|
||||
xechar_t command_line_[2048];
|
||||
shared_ptr<ExportResolver> export_resolver_;
|
||||
shared_ptr<fs::FileSystem> filesystem_;
|
||||
|
||||
auto_ptr<xboxkrnl::XboxkrnlModule> xboxkrnl_;
|
||||
auto_ptr<xam::XamModule> xam_;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/fs/device.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
Device::Device(xe_pal_ref pal) {
|
||||
pal_ = xe_pal_retain(pal);
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
xe_pal_release(pal_);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "kernel/fs/devices/disc_image_device.h"
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
DiscImageDevice::DiscImageDevice(xe_pal_ref pal, const xechar_t* local_path) :
|
||||
Device(pal) {
|
||||
local_path_ = xestrdup(local_path);
|
||||
}
|
||||
|
||||
DiscImageDevice::~DiscImageDevice() {
|
||||
xe_free(local_path_);
|
||||
}
|
||||
|
||||
Entry* DiscImageDevice::ResolvePath(const char* path) {
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
#define XENIA_KERNEL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/fs/device.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class DiscImageDevice : public Device {
|
||||
public:
|
||||
DiscImageDevice(xe_pal_ref pal, const xechar_t* local_path);
|
||||
virtual ~DiscImageDevice();
|
||||
|
||||
virtual Entry* ResolvePath(const char* path);
|
||||
|
||||
private:
|
||||
xechar_t* local_path_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "kernel/fs/devices/local_directory_device.h"
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
LocalDirectoryDevice::LocalDirectoryDevice(xe_pal_ref pal,
|
||||
const xechar_t* local_path) :
|
||||
Device(pal) {
|
||||
local_path_ = xestrdup(local_path);
|
||||
}
|
||||
|
||||
LocalDirectoryDevice::~LocalDirectoryDevice() {
|
||||
xe_free(local_path_);
|
||||
}
|
||||
|
||||
Entry* LocalDirectoryDevice::ResolvePath(const char* path) {
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_FS_DEVICES_LOCAL_DIRECTORY_DEVICE_H_
|
||||
#define XENIA_KERNEL_FS_DEVICES_LOCAL_DIRECTORY_DEVICE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/fs/device.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class LocalDirectoryDevice : public Device {
|
||||
public:
|
||||
LocalDirectoryDevice(xe_pal_ref pal, const xechar_t* local_path);
|
||||
virtual ~LocalDirectoryDevice();
|
||||
|
||||
virtual Entry* ResolvePath(const char* path);
|
||||
|
||||
private:
|
||||
xechar_t* local_path_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_FS_DEVICES_LOCAL_DIRECTORY_DEVICE_H_
|
|
@ -0,0 +1,7 @@
|
|||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'disc_image_device.cc',
|
||||
'local_directory_device.cc',
|
||||
],
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/fs/entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
Entry::Entry(Type type, Device* device, const char* path) :
|
||||
type_(type),
|
||||
device_(device) {
|
||||
path_ = xestrdupa(path);
|
||||
// TODO(benvanik): last index of \, unless \ at end, then before that
|
||||
name_ = NULL;
|
||||
}
|
||||
|
||||
Entry::~Entry() {
|
||||
xe_free(path_);
|
||||
xe_free(name_);
|
||||
}
|
||||
|
||||
Entry::Type Entry::type() {
|
||||
return type_;
|
||||
}
|
||||
|
||||
Device* Entry::device() {
|
||||
return device_;
|
||||
}
|
||||
|
||||
const char* Entry::path() {
|
||||
return path_;
|
||||
}
|
||||
|
||||
const char* Entry::name() {
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
FileEntry::FileEntry(Device* device, const char* path) :
|
||||
Entry(kTypeFile, device, path) {
|
||||
}
|
||||
|
||||
FileEntry::~FileEntry() {
|
||||
}
|
||||
|
||||
|
||||
DirectoryEntry::DirectoryEntry(Device* device, const char* path) :
|
||||
Entry(kTypeDirectory, device, path) {
|
||||
}
|
||||
|
||||
DirectoryEntry::~DirectoryEntry() {
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/fs/filesystem.h>
|
||||
|
||||
#include "kernel/fs/devices/disc_image_device.h"
|
||||
#include "kernel/fs/devices/local_directory_device.h"
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
FileSystem::FileSystem(xe_pal_ref pal) {
|
||||
pal_ = xe_pal_retain(pal);
|
||||
}
|
||||
|
||||
FileSystem::~FileSystem() {
|
||||
xe_pal_release(pal_);
|
||||
}
|
||||
|
||||
int FileSystem::RegisterDevice(const char* path, Device* device) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FileSystem::RegisterLocalDirectoryDevice(
|
||||
const char* path, const xechar_t* local_path) {
|
||||
Device* device = new LocalDirectoryDevice(pal_, local_path);
|
||||
return RegisterDevice(path, device);
|
||||
}
|
||||
|
||||
int FileSystem::RegisterDiscImageDevice(
|
||||
const char* path, const xechar_t* local_path) {
|
||||
Device* device = new DiscImageDevice(pal_, local_path);
|
||||
return RegisterDevice(path, device);
|
||||
}
|
||||
|
||||
int FileSystem::CreateSymbolicLink(const char* path, const char* target) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FileSystem::DeleteSymbolicLink(const char* path) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Entry* FileSystem::ResolvePath(const char* path) {
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'device.cc',
|
||||
'entry.cc',
|
||||
'filesystem.cc',
|
||||
],
|
||||
|
||||
'includes': [
|
||||
'devices/sources.gypi',
|
||||
],
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
using namespace xe;
|
||||
using namespace xe::cpu;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
Runtime::Runtime(xe_pal_ref pal, shared_ptr<cpu::Processor> processor,
|
||||
|
@ -25,6 +26,8 @@ Runtime::Runtime(xe_pal_ref pal, shared_ptr<cpu::Processor> processor,
|
|||
XEIGNORE(xestrcpy(command_line_, XECOUNT(command_line_), command_line));
|
||||
export_resolver_ = shared_ptr<ExportResolver>(new ExportResolver());
|
||||
|
||||
filesystem_ = shared_ptr<FileSystem>(new FileSystem(pal_));
|
||||
|
||||
xboxkrnl_ = auto_ptr<xboxkrnl::XboxkrnlModule>(
|
||||
new xboxkrnl::XboxkrnlModule(this));
|
||||
xam_ = auto_ptr<xam::XamModule>(
|
||||
|
@ -36,6 +39,10 @@ Runtime::~Runtime() {
|
|||
xe_pal_release(pal_);
|
||||
}
|
||||
|
||||
const xechar_t* Runtime::command_line() {
|
||||
return command_line_;
|
||||
}
|
||||
|
||||
xe_pal_ref Runtime::pal() {
|
||||
return xe_pal_retain(pal_);
|
||||
}
|
||||
|
@ -52,8 +59,8 @@ shared_ptr<ExportResolver> Runtime::export_resolver() {
|
|||
return export_resolver_;
|
||||
}
|
||||
|
||||
const xechar_t* Runtime::command_line() {
|
||||
return command_line_;
|
||||
shared_ptr<FileSystem> Runtime::filesystem() {
|
||||
return filesystem_;
|
||||
}
|
||||
|
||||
int Runtime::LaunchModule(const xechar_t* path) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
],
|
||||
|
||||
'includes': [
|
||||
'fs/sources.gypi',
|
||||
'modules/sources.gypi',
|
||||
],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue