QueryFileSystemAttributes/QueryVolume for STFS/ISO.
This commit is contained in:
parent
58e71c7ff3
commit
1a70606904
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <xenia/kernel/fs/device.h>
|
||||
|
||||
#include <xenia/kernel/objects/xfile.h>
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace fs {
|
||||
|
@ -17,6 +19,44 @@ Device::Device(const std::string& path) : path_(path) {}
|
|||
|
||||
Device::~Device() = default;
|
||||
|
||||
// TODO(gibbed): call into HostPathDevice?
|
||||
X_STATUS Device::QueryVolume(XVolumeInfo* out_info, size_t length) {
|
||||
assert_not_null(out_info);
|
||||
const char* name = "test"; // TODO(gibbed): actual value
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
size_t name_length = strlen(name);
|
||||
if (((uint8_t*)&out_info->label[0]) + name_length > end) {
|
||||
return X_STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
out_info->creation_time = 0;
|
||||
out_info->serial_number = 12345678;
|
||||
out_info->supports_objects = 0;
|
||||
out_info->label_length = (uint32_t)name_length;
|
||||
memcpy(out_info->label, name, name_length);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO(gibbed): call into HostPathDevice?
|
||||
X_STATUS Device::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||
size_t length) {
|
||||
assert_not_null(out_info);
|
||||
const char* name = "test"; // TODO(gibbed): actual value
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
size_t name_length = strlen(name);
|
||||
if (((uint8_t*)&out_info->fs_name[0]) + name_length > end) {
|
||||
return X_STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
out_info->attributes = 0;
|
||||
out_info->maximum_component_name_length = 255; // TODO(gibbed): actual value
|
||||
out_info->fs_name_length = (uint32_t)name_length;
|
||||
memcpy(out_info->fs_name, name, name_length);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -29,9 +29,9 @@ class Device {
|
|||
|
||||
virtual std::unique_ptr<Entry> ResolvePath(const char* path) = 0;
|
||||
|
||||
virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) = 0;
|
||||
virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length);
|
||||
virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||
size_t length) = 0;
|
||||
size_t length);
|
||||
|
||||
protected:
|
||||
std::string path_;
|
||||
|
|
|
@ -68,17 +68,6 @@ std::unique_ptr<Entry> DiscImageDevice::ResolvePath(const char* path) {
|
|||
gdfx_entry);
|
||||
}
|
||||
|
||||
X_STATUS DiscImageDevice::QueryVolume(XVolumeInfo* out_info, size_t length) {
|
||||
assert_always();
|
||||
return X_STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
X_STATUS DiscImageDevice::QueryFileSystemAttributes(
|
||||
XFileSystemAttributeInfo* out_info, size_t length) {
|
||||
assert_always();
|
||||
return X_STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -32,10 +32,6 @@ class DiscImageDevice : public Device {
|
|||
|
||||
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||
|
||||
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
||||
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||
size_t length) override;
|
||||
|
||||
private:
|
||||
std::wstring local_path_;
|
||||
std::unique_ptr<poly::MappedMemory> mmap_;
|
||||
|
|
|
@ -51,30 +51,41 @@ X_STATUS DiscImageEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length,
|
|||
const char* file_name, bool restart) {
|
||||
assert_not_null(out_info);
|
||||
|
||||
if (restart == true && gdfx_entry_iterator_ != gdfx_entry_->children.end()) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||
}
|
||||
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.begin();
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
// TODO(benvanik): move to common code.
|
||||
assert_null(file_name);
|
||||
GDFXEntry* entry = nullptr;
|
||||
if (file_name) {
|
||||
// Specified filename, return just that info.
|
||||
assert_true(std::strchr(file_name, '*') == nullptr);
|
||||
entry = gdfx_entry_->GetChild(file_name);
|
||||
if (!entry) {
|
||||
return X_STATUS_NO_SUCH_FILE;
|
||||
}
|
||||
} else {
|
||||
++gdfx_entry_iterator_;
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
if (restart == true &&
|
||||
gdfx_entry_iterator_ != gdfx_entry_->children.end()) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||
}
|
||||
}
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.begin();
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
} else {
|
||||
++gdfx_entry_iterator_;
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
auto entry = *gdfx_entry_iterator_;
|
||||
auto entry_name = entry->name;
|
||||
|
||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
entry = *gdfx_entry_iterator_;
|
||||
auto entry_name = entry->name;
|
||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||
return X_STATUS_NO_MORE_FILES;
|
||||
}
|
||||
}
|
||||
|
||||
out_info->next_entry_offset = 0;
|
||||
|
@ -86,8 +97,8 @@ X_STATUS DiscImageEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length,
|
|||
out_info->end_of_file = entry->size;
|
||||
out_info->allocation_size = 2048;
|
||||
out_info->attributes = (X_FILE_ATTRIBUTES)entry->attributes;
|
||||
out_info->file_name_length = static_cast<uint32_t>(entry_name.size());
|
||||
memcpy(out_info->file_name, entry_name.c_str(), entry_name.size());
|
||||
out_info->file_name_length = static_cast<uint32_t>(entry->name.size());
|
||||
memcpy(out_info->file_name, entry->name.c_str(), entry->name.size());
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -41,44 +41,6 @@ std::unique_ptr<Entry> HostPathDevice::ResolvePath(const char* path) {
|
|||
return std::make_unique<HostPathEntry>(type, this, path, full_path);
|
||||
}
|
||||
|
||||
// TODO(gibbed): call into HostPathDevice?
|
||||
X_STATUS HostPathDevice::QueryVolume(XVolumeInfo* out_info, size_t length) {
|
||||
assert_not_null(out_info);
|
||||
const char* name = "test"; // TODO(gibbed): actual value
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
size_t name_length = strlen(name);
|
||||
if (((uint8_t*)&out_info->label[0]) + name_length > end) {
|
||||
return X_STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
out_info->creation_time = 0;
|
||||
out_info->serial_number = 12345678;
|
||||
out_info->supports_objects = 0;
|
||||
out_info->label_length = (uint32_t)name_length;
|
||||
memcpy(out_info->label, name, name_length);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO(gibbed): call into HostPathDevice?
|
||||
X_STATUS HostPathDevice::QueryFileSystemAttributes(
|
||||
XFileSystemAttributeInfo* out_info, size_t length) {
|
||||
assert_not_null(out_info);
|
||||
const char* name = "test"; // TODO(gibbed): actual value
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
size_t name_length = strlen(name);
|
||||
if (((uint8_t*)&out_info->fs_name[0]) + name_length > end) {
|
||||
return X_STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
out_info->attributes = 0;
|
||||
out_info->maximum_component_name_length = 255; // TODO(gibbed): actual value
|
||||
out_info->fs_name_length = (uint32_t)name_length;
|
||||
memcpy(out_info->fs_name, name, name_length);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -26,10 +26,6 @@ class HostPathDevice : public Device {
|
|||
|
||||
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||
|
||||
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
||||
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||
size_t length) override;
|
||||
|
||||
private:
|
||||
std::wstring local_path_;
|
||||
};
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <poly/math.h>
|
||||
#include <xenia/kernel/fs/stfs.h>
|
||||
#include <xenia/kernel/fs/devices/stfs_container_entry.h>
|
||||
#include <xenia/kernel/objects/xfile.h>
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
@ -68,18 +69,6 @@ std::unique_ptr<Entry> STFSContainerDevice::ResolvePath(const char* path) {
|
|||
stfs_entry);
|
||||
}
|
||||
|
||||
X_STATUS STFSContainerDevice::QueryVolume(XVolumeInfo* out_info,
|
||||
size_t length) {
|
||||
assert_always();
|
||||
return X_STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
X_STATUS STFSContainerDevice::QueryFileSystemAttributes(
|
||||
XFileSystemAttributeInfo* out_info, size_t length) {
|
||||
assert_always();
|
||||
return X_STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -32,10 +32,6 @@ class STFSContainerDevice : public Device {
|
|||
|
||||
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||
|
||||
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
||||
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||
size_t length) override;
|
||||
|
||||
private:
|
||||
std::wstring local_path_;
|
||||
std::unique_ptr<poly::MappedMemory> mmap_;
|
||||
|
|
|
@ -45,30 +45,39 @@ X_STATUS STFSContainerEntry::QueryDirectory(XDirectoryInfo* out_info,
|
|||
bool restart) {
|
||||
assert_not_null(out_info);
|
||||
|
||||
if (restart && stfs_entry_iterator_ != stfs_entry_->children.end()) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.end();
|
||||
}
|
||||
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.begin();
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
// TODO(benvanik): move to common code.
|
||||
STFSEntry* entry = nullptr;
|
||||
if (file_name) {
|
||||
// Specified filename, return just that info.
|
||||
assert_true(std::strchr(file_name, '*') == nullptr);
|
||||
entry = stfs_entry_->GetChild(file_name);
|
||||
if (!entry) {
|
||||
return X_STATUS_NO_SUCH_FILE;
|
||||
}
|
||||
} else {
|
||||
++stfs_entry_iterator_;
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
if (restart && stfs_entry_iterator_ != stfs_entry_->children.end()) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.end();
|
||||
}
|
||||
}
|
||||
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.begin();
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
} else {
|
||||
++stfs_entry_iterator_;
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
auto entry = stfs_entry_iterator_->get();
|
||||
auto entry_name = entry->name;
|
||||
|
||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.end();
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
auto end = (uint8_t*)out_info + length;
|
||||
entry = stfs_entry_iterator_->get();
|
||||
auto entry_name = entry->name;
|
||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.end();
|
||||
return X_STATUS_NO_MORE_FILES;
|
||||
}
|
||||
}
|
||||
|
||||
out_info->file_index = 0xCDCDCDCD;
|
||||
|
@ -79,8 +88,8 @@ X_STATUS STFSContainerEntry::QueryDirectory(XDirectoryInfo* out_info,
|
|||
out_info->end_of_file = entry->size;
|
||||
out_info->allocation_size = 4096;
|
||||
out_info->attributes = entry->attributes;
|
||||
out_info->file_name_length = static_cast<uint32_t>(entry_name.size());
|
||||
memcpy(out_info->file_name, entry_name.c_str(), entry_name.size());
|
||||
out_info->file_name_length = static_cast<uint32_t>(entry->name.size());
|
||||
memcpy(out_info->file_name, entry->name.c_str(), entry->name.size());
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue