Removing unneeded fs entry type.

This commit is contained in:
Ben Vanik 2015-02-09 16:59:28 -08:00
parent 78451a4e9e
commit cc6d03ab2c
13 changed files with 18 additions and 38 deletions

View File

@ -61,11 +61,7 @@ std::unique_ptr<Entry> DiscImageDevice::ResolvePath(const char* path) {
} }
} }
Entry::Type type = gdfx_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY return std::make_unique<DiscImageEntry>(this, path, mmap_.get(), gdfx_entry);
? Entry::Type::DIRECTORY
: Entry::Type::FILE;
return std::make_unique<DiscImageEntry>(type, this, path, mmap_.get(),
gdfx_entry);
} }
} // namespace fs } // namespace fs

View File

@ -26,9 +26,9 @@ class DiscImageMemoryMapping : public MemoryMapping {
~DiscImageMemoryMapping() override = default; ~DiscImageMemoryMapping() override = default;
}; };
DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path, DiscImageEntry::DiscImageEntry(Device* device, const char* path,
poly::MappedMemory* mmap, GDFXEntry* gdfx_entry) poly::MappedMemory* mmap, GDFXEntry* gdfx_entry)
: Entry(type, device, path), : Entry(device, path),
mmap_(mmap), mmap_(mmap),
gdfx_entry_(gdfx_entry), gdfx_entry_(gdfx_entry),
gdfx_entry_iterator_(gdfx_entry->children.end()) {} gdfx_entry_iterator_(gdfx_entry->children.end()) {}

View File

@ -24,8 +24,8 @@ class GDFXEntry;
class DiscImageEntry : public Entry { class DiscImageEntry : public Entry {
public: public:
DiscImageEntry(Type type, Device* device, const char* path, DiscImageEntry(Device* device, const char* path, poly::MappedMemory* mmap,
poly::MappedMemory* mmap, GDFXEntry* gdfx_entry); GDFXEntry* gdfx_entry);
~DiscImageEntry() override; ~DiscImageEntry() override;
poly::MappedMemory* mmap() const { return mmap_; } poly::MappedMemory* mmap() const { return mmap_; }

View File

@ -37,8 +37,7 @@ std::unique_ptr<Entry> HostPathDevice::ResolvePath(const char* path) {
// TODO(benvanik): fail if does not exit // TODO(benvanik): fail if does not exit
// TODO(benvanik): switch based on type // TODO(benvanik): switch based on type
auto type = Entry::Type::FILE; return std::make_unique<HostPathEntry>(this, path, full_path);
return std::make_unique<HostPathEntry>(type, this, path, full_path);
} }
} // namespace fs } // namespace fs

View File

@ -25,9 +25,9 @@ class HostPathMemoryMapping : public MemoryMapping {
std::unique_ptr<poly::MappedMemory> mmap_; std::unique_ptr<poly::MappedMemory> mmap_;
}; };
HostPathEntry::HostPathEntry(Type type, Device* device, const char* path, HostPathEntry::HostPathEntry(Device* device, const char* path,
const std::wstring& local_path) const std::wstring& local_path)
: Entry(type, device, path), : Entry(device, path),
local_path_(local_path), local_path_(local_path),
find_file_(INVALID_HANDLE_VALUE) {} find_file_(INVALID_HANDLE_VALUE) {}

View File

@ -19,7 +19,7 @@ namespace fs {
class HostPathEntry : public Entry { class HostPathEntry : public Entry {
public: public:
HostPathEntry(Type type, Device* device, const char* path, HostPathEntry(Device* device, const char* path,
const std::wstring& local_path); const std::wstring& local_path);
~HostPathEntry() override; ~HostPathEntry() override;

View File

@ -62,10 +62,7 @@ std::unique_ptr<Entry> STFSContainerDevice::ResolvePath(const char* path) {
} }
} }
Entry::Type type = stfs_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY return std::make_unique<STFSContainerEntry>(this, path, mmap_.get(),
? Entry::Type::DIRECTORY
: Entry::Type::FILE;
return std::make_unique<STFSContainerEntry>(type, this, path, mmap_.get(),
stfs_entry); stfs_entry);
} }

View File

@ -16,11 +16,10 @@ namespace xe {
namespace kernel { namespace kernel {
namespace fs { namespace fs {
STFSContainerEntry::STFSContainerEntry(Type type, Device* device, STFSContainerEntry::STFSContainerEntry(Device* device, const char* path,
const char* path,
poly::MappedMemory* mmap, poly::MappedMemory* mmap,
STFSEntry* stfs_entry) STFSEntry* stfs_entry)
: Entry(type, device, path), : Entry(device, path),
mmap_(mmap), mmap_(mmap),
stfs_entry_(stfs_entry), stfs_entry_(stfs_entry),
stfs_entry_iterator_(stfs_entry->children.end()) {} stfs_entry_iterator_(stfs_entry->children.end()) {}

View File

@ -24,8 +24,8 @@ class STFSEntry;
class STFSContainerEntry : public Entry { class STFSContainerEntry : public Entry {
public: public:
STFSContainerEntry(Type type, Device* device, const char* path, STFSContainerEntry(Device* device, const char* path, poly::MappedMemory* mmap,
poly::MappedMemory* mmap, STFSEntry* stfs_entry); STFSEntry* stfs_entry);
~STFSContainerEntry() override; ~STFSContainerEntry() override;
poly::MappedMemory* mmap() const { return mmap_; } poly::MappedMemory* mmap() const { return mmap_; }

View File

@ -19,8 +19,8 @@ MemoryMapping::MemoryMapping(uint8_t* address, size_t length)
MemoryMapping::~MemoryMapping() {} MemoryMapping::~MemoryMapping() {}
Entry::Entry(Type type, Device* device, const std::string& path) Entry::Entry(Device* device, const std::string& path)
: type_(type), device_(device), path_(path) { : device_(device), path_(path) {
assert_not_null(device); assert_not_null(device);
absolute_path_ = device->path() + path; absolute_path_ = device->path() + path;
// TODO(benvanik): last index of \, unless \ at end, then before that // TODO(benvanik): last index of \, unless \ at end, then before that

View File

@ -53,15 +53,9 @@ class MemoryMapping {
class Entry { class Entry {
public: public:
enum class Type { Entry(Device* device, const std::string& path);
FILE,
DIRECTORY,
};
Entry(Type type, Device* device, const std::string& path);
virtual ~Entry(); virtual ~Entry();
Type type() const { return type_; }
Device* device() const { return device_; } Device* device() const { return device_; }
const std::string& path() const { return path_; } const std::string& path() const { return path_; }
const std::string& absolute_path() const { return absolute_path_; } const std::string& absolute_path() const { return absolute_path_; }
@ -82,7 +76,6 @@ class Entry {
XFile** out_file) = 0; XFile** out_file) = 0;
private: private:
Type type_;
Device* device_; Device* device_;
std::string path_; std::string path_;
std::string absolute_path_; std::string absolute_path_;

View File

@ -41,10 +41,6 @@ X_STATUS XUserModule::LoadFromFile(const char* path) {
XELOGE("File not found: %s", path); XELOGE("File not found: %s", path);
return X_STATUS_NO_SUCH_FILE; return X_STATUS_NO_SUCH_FILE;
} }
if (fs_entry->type() != fs::Entry::Type::FILE) {
XELOGE("Invalid file type: %s", path);
return X_STATUS_NO_SUCH_FILE;
}
// If the FS supports mapping, map the file in and load from that. // If the FS supports mapping, map the file in and load from that.
if (fs_entry->can_map()) { if (fs_entry->can_map()) {

View File

@ -469,7 +469,7 @@ SHIM_CALL NtQueryFullAttributesFile_shim(PPCContext* ppc_state,
// Resolve the file using the virtual file system. // Resolve the file using the virtual file system.
FileSystem* fs = state->file_system(); FileSystem* fs = state->file_system();
auto entry = fs->ResolvePath(object_name); auto entry = fs->ResolvePath(object_name);
if (entry && entry->type() == Entry::Type::FILE) { if (entry) {
// Found. // Found.
XFileInfo file_info; XFileInfo file_info;
result = entry->QueryInfo(&file_info); result = entry->QueryInfo(&file_info);