QueryDirectory for STFS.
This commit is contained in:
parent
7da2ad30b0
commit
268bbf105d
|
@ -67,11 +67,7 @@ X_STATUS DiscImageEntry::QueryInfo(XFileInfo* out_info) {
|
|||
X_STATUS DiscImageEntry::QueryDirectory(
|
||||
XDirectoryInfo* out_info, size_t length, bool restart) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
if (length < sizeof(XDirectoryInfo)) {
|
||||
return X_STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
|
||||
memset(out_info, 0, length);
|
||||
xe_zero_struct(out_info, length);
|
||||
|
||||
if (restart == true && gdfx_entry_iterator_ != gdfx_entry_->children.end()) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||
|
@ -82,21 +78,18 @@ X_STATUS DiscImageEntry::QueryDirectory(
|
|||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
++gdfx_entry_iterator_;
|
||||
if (gdfx_entry_iterator_ == gdfx_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
XDirectoryInfo* current;
|
||||
|
||||
auto current_buf = (uint8_t*)out_info;
|
||||
auto end = current_buf + length;
|
||||
|
||||
current = (XDirectoryInfo*)current_buf;
|
||||
if (((uint8_t*)¤t->file_name[0]) + strlen((*gdfx_entry_iterator_)->name.c_str()) > end) {
|
||||
XDirectoryInfo* current = (XDirectoryInfo*)current_buf;
|
||||
if (((uint8_t*)¤t->file_name[0]) + xestrlena((*gdfx_entry_iterator_)->name.c_str()) > end) {
|
||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
@ -105,7 +98,7 @@ X_STATUS DiscImageEntry::QueryDirectory(
|
|||
auto entry = *gdfx_entry_iterator_;
|
||||
|
||||
auto file_name = entry->name.c_str();
|
||||
size_t file_name_length = strlen(file_name);
|
||||
size_t file_name_length = xestrlena(file_name);
|
||||
if (((uint8_t*)&((XDirectoryInfo*)current_buf)->file_name[0]) + file_name_length > end) {
|
||||
break;
|
||||
}
|
||||
|
@ -128,7 +121,8 @@ X_STATUS DiscImageEntry::QueryDirectory(
|
|||
|
||||
current->next_entry_offset = (uint32_t)(next_buf - current_buf);
|
||||
current_buf = next_buf;
|
||||
} while (current_buf < end && (++gdfx_entry_iterator_) != gdfx_entry_->children.end());
|
||||
} while (current_buf < end &&
|
||||
(++gdfx_entry_iterator_) != gdfx_entry_->children.end());
|
||||
current->next_entry_offset = 0;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -76,11 +76,7 @@ X_STATUS HostPathEntry::QueryInfo(XFileInfo* out_info) {
|
|||
X_STATUS HostPathEntry::QueryDirectory(
|
||||
XDirectoryInfo* out_info, size_t length, bool restart) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
if (length < sizeof(XDirectoryInfo)) {
|
||||
return X_STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
|
||||
memset(out_info, 0, length);
|
||||
xe_zero_struct(out_info, length);
|
||||
|
||||
WIN32_FIND_DATA ffd;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ STFSContainerEntry::STFSContainerEntry(
|
|||
Type type, Device* device, const char* path,
|
||||
xe_mmap_ref mmap, STFSEntry* stfs_entry) :
|
||||
stfs_entry_(stfs_entry),
|
||||
stfs_entry_iterator_(stfs_entry->children.end()),
|
||||
Entry(type, device, path) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
|
@ -42,9 +43,67 @@ X_STATUS STFSContainerEntry::QueryInfo(XFileInfo* out_info) {
|
|||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS STFSContainerEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length, bool restart) {
|
||||
XEASSERTALWAYS();
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
X_STATUS STFSContainerEntry::QueryDirectory(
|
||||
XDirectoryInfo* out_info, size_t length, bool restart) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
xe_zero_struct(out_info, length);
|
||||
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
++stfs_entry_iterator_;
|
||||
if (stfs_entry_iterator_ == stfs_entry_->children.end()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
auto current_buf = (uint8_t*)out_info;
|
||||
auto end = current_buf + length;
|
||||
|
||||
XDirectoryInfo* current = (XDirectoryInfo*)current_buf;
|
||||
if (((uint8_t*)¤t->file_name[0]) + xestrlena((*stfs_entry_iterator_)->name.c_str()) > end) {
|
||||
stfs_entry_iterator_ = stfs_entry_->children.end();
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
do {
|
||||
auto entry = *stfs_entry_iterator_;
|
||||
|
||||
auto file_name = entry->name.c_str();
|
||||
size_t file_name_length = xestrlena(file_name);
|
||||
if (((uint8_t*)&((XDirectoryInfo*)current_buf)->file_name[0]) + file_name_length > end) {
|
||||
break;
|
||||
}
|
||||
|
||||
current = (XDirectoryInfo*)current_buf;
|
||||
current->file_index = 0xCDCDCDCD;
|
||||
current->creation_time = entry->update_timestamp;
|
||||
current->last_access_time = entry->access_timestamp;
|
||||
current->last_write_time = entry->update_timestamp;
|
||||
current->change_time = entry->update_timestamp;
|
||||
current->end_of_file = entry->size;
|
||||
current->allocation_size = 4096;
|
||||
current->attributes = entry->attributes;
|
||||
|
||||
current->file_name_length = (uint32_t)file_name_length;
|
||||
memcpy(current->file_name, file_name, file_name_length);
|
||||
|
||||
auto next_buf = (((uint8_t*)¤t->file_name[0]) + file_name_length);
|
||||
next_buf += 8 - ((uint8_t)next_buf % 8);
|
||||
|
||||
current->next_entry_offset = (uint32_t)(next_buf - current_buf);
|
||||
current_buf = next_buf;
|
||||
} while (current_buf < end &&
|
||||
(++stfs_entry_iterator_) != stfs_entry_->children.end());
|
||||
current->next_entry_offset = 0;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS STFSContainerEntry::Open(
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
STFSEntry* stfs_entry_;
|
||||
std::vector<STFSEntry*>::iterator stfs_entry_iterator_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -148,15 +148,6 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length,
|
|||
|
||||
const uint8_t *pp = p + opt_header->offset;
|
||||
switch (opt_header->key) {
|
||||
default:
|
||||
XELOGW("Unknown XEX header key %.8X", opt_header->key);
|
||||
break;
|
||||
case XEX_HEADER_CHECKSUM_TIMESTAMP:
|
||||
case XEX_HEADER_ORIGINAL_PE_NAME:
|
||||
case XEX_HEADER_LAN_KEY:
|
||||
case XEX_HEADER_XBOX360_LOGO:
|
||||
// Ignored.
|
||||
break;
|
||||
case XEX_HEADER_SYSTEM_FLAGS:
|
||||
header->system_flags = (xe_xex2_system_flags)data_offset;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue