QueryFileSystemAttributes/QueryVolume for STFS/ISO.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user