Fix VFS files not having correct paths recorded.

This commit is contained in:
Dr. Chat 2015-12-17 15:35:39 -06:00 committed by Ben Vanik
parent ab9fac9a98
commit 9cf324f689
7 changed files with 39 additions and 11 deletions

View File

@ -118,8 +118,8 @@ bool DiscImageDevice::ReadEntry(ParseState* state, const uint8_t* buffer,
return false;
}
auto entry = new DiscImageEntry(this, parent, std::string(name, name_length),
mmap_.get());
auto entry = DiscImageEntry::Create(
this, parent, std::string(name, name_length), mmap_.get());
entry->attributes_ = attributes | kFileAttributeReadOnly;
entry->size_ = length;
entry->allocation_size_ = xe::round_up(length, bytes_per_sector());
@ -127,9 +127,6 @@ bool DiscImageDevice::ReadEntry(ParseState* state, const uint8_t* buffer,
entry->access_timestamp_ = 0;
entry->write_timestamp_ = 0;
// Add to parent.
parent->children_.emplace_back(std::unique_ptr<Entry>(entry));
if (attributes & kFileAttributeDirectory) {
// Folder.
entry->data_offset_ = 0;
@ -143,7 +140,7 @@ bool DiscImageDevice::ReadEntry(ParseState* state, const uint8_t* buffer,
// Read child list.
uint8_t* folder_ptr =
state->ptr + state->game_offset + (sector * kXESectorSize);
if (!ReadEntry(state, folder_ptr, 0, entry)) {
if (!ReadEntry(state, folder_ptr, 0, entry.get())) {
return false;
}
}
@ -153,6 +150,9 @@ bool DiscImageDevice::ReadEntry(ParseState* state, const uint8_t* buffer,
entry->data_size_ = length;
}
// Add to parent.
parent->children_.emplace_back(std::move(entry));
// Read next file in the list.
if (node_r && !ReadEntry(state, buffer, node_r, parent)) {
return false;

View File

@ -26,6 +26,16 @@ DiscImageEntry::DiscImageEntry(Device* device, Entry* parent, std::string path,
DiscImageEntry::~DiscImageEntry() = default;
std::unique_ptr<DiscImageEntry> DiscImageEntry::Create(Device* device,
Entry* parent,
std::string name,
MappedMemory* mmap) {
auto path = xe::join_paths(parent->path(), name);
auto entry = std::make_unique<DiscImageEntry>(device, parent, path, mmap);
return std::move(entry);
}
X_STATUS DiscImageEntry::Open(uint32_t desired_access, File** out_file) {
*out_file = new DiscImageFile(desired_access, this);
return X_STATUS_SUCCESS;

View File

@ -28,6 +28,10 @@ class DiscImageEntry : public Entry {
MappedMemory* mmap);
~DiscImageEntry() override;
static std::unique_ptr<DiscImageEntry> Create(Device* device, Entry* parent,
std::string name,
MappedMemory* mmap);
MappedMemory* mmap() const { return mmap_; }
size_t data_offset() const { return data_offset_; }
size_t data_size() const { return data_size_; }

View File

@ -29,8 +29,9 @@ HostPathEntry::~HostPathEntry() = default;
HostPathEntry* HostPathEntry::Create(Device* device, Entry* parent,
const std::wstring& full_path,
xe::filesystem::FileInfo file_info) {
auto entry = new HostPathEntry(device, parent, xe::to_string(file_info.name),
full_path);
auto path = xe::join_paths(parent->path(), xe::to_string(file_info.name));
auto entry = new HostPathEntry(device, parent, path, full_path);
entry->create_timestamp_ = file_info.create_timestamp;
entry->access_timestamp_ = file_info.access_timestamp;
entry->write_timestamp_ = file_info.write_timestamp;

View File

@ -168,7 +168,7 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries(
parent_entry = all_entries[path_indicator];
}
auto entry = new StfsContainerEntry(
auto entry = StfsContainerEntry::Create(
this, parent_entry,
std::string(reinterpret_cast<const char*>(filename),
filename_length_flags & 0x3F),
@ -187,7 +187,7 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries(
entry->create_timestamp_ = update_timestamp;
entry->access_timestamp_ = access_timestamp;
entry->write_timestamp_ = update_timestamp;
all_entries.push_back(entry);
all_entries.push_back(entry.get());
// Fill in all block records.
// It's easier to do this now and just look them up later, at the cost
@ -212,7 +212,7 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries(
}
}
parent_entry->children_.emplace_back(std::unique_ptr<Entry>(entry));
parent_entry->children_.emplace_back(std::move(entry));
}
auto block_hash = GetBlockHash(map_ptr, table_block_index, 0);

View File

@ -24,6 +24,14 @@ StfsContainerEntry::StfsContainerEntry(Device* device, Entry* parent,
StfsContainerEntry::~StfsContainerEntry() = default;
std::unique_ptr<StfsContainerEntry> StfsContainerEntry::Create(
Device* device, Entry* parent, std::string name, MappedMemory* mmap) {
auto path = xe::join_paths(parent->path(), name);
auto entry = std::make_unique<StfsContainerEntry>(device, parent, path, mmap);
return std::move(entry);
}
X_STATUS StfsContainerEntry::Open(uint32_t desired_access, File** out_file) {
*out_file = new StfsContainerFile(desired_access, this);
return X_STATUS_SUCCESS;

View File

@ -29,6 +29,11 @@ class StfsContainerEntry : public Entry {
MappedMemory* mmap);
~StfsContainerEntry() override;
static std::unique_ptr<StfsContainerEntry> Create(Device* device,
Entry* parent,
std::string name,
MappedMemory* mmap);
MappedMemory* mmap() const { return mmap_; }
size_t data_offset() const { return data_offset_; }
size_t data_size() const { return data_size_; }