[Kernel] Added support for writing/reading GPD files

This breaks settings in games that are using them and savefiles in games that use settings to store progress
This commit is contained in:
Gliniak
2024-12-15 13:58:08 +01:00
committed by Radosław Gliński
parent ccf7adf015
commit 1110cdd372
58 changed files with 4642 additions and 2122 deletions

View File

@@ -51,5 +51,6 @@ std::unique_ptr<MappedMemory> DiscImageEntry::OpenMapped(
return mmap_->Slice(real_offset, real_length);
}
bool DiscImageEntry::DeleteEntryInternal(Entry* entry) { return false; }
} // namespace vfs
} // namespace xe

View File

@@ -45,6 +45,8 @@ class DiscImageEntry : public Entry {
private:
friend class DiscImageDevice;
bool DeleteEntryInternal(Entry* entry) override;
MappedMemory* mmap_;
size_t data_offset_;
size_t data_size_;

View File

@@ -45,5 +45,7 @@ std::unique_ptr<MappedMemory> DiscZarchiveEntry::OpenMapped(
return nullptr;
}
bool DiscZarchiveEntry::DeleteEntryInternal(Entry* entry) { return false; }
} // namespace vfs
} // namespace xe

View File

@@ -45,6 +45,8 @@ class DiscZarchiveEntry : public Entry {
friend class DiscZarchiveDevice;
friend class DiscZarchiveFile;
bool DeleteEntryInternal(Entry* entry) override;
uint32_t handle_;
size_t data_offset_;
size_t data_size_;

View File

@@ -104,10 +104,20 @@ bool HostPathEntry::DeleteEntryInternal(Entry* entry) {
auto removed = std::filesystem::remove_all(full_path, ec);
return removed >= 1 && removed != static_cast<std::uintmax_t>(-1);
} else {
// Delete file only if it exists.
return !std::filesystem::is_directory(full_path) &&
(!std::filesystem::exists(full_path) ||
std::filesystem::remove(full_path, ec));
// Skip directories, they we're handled above.
if (std::filesystem::is_directory(full_path)) {
return false;
}
if (std::filesystem::exists(full_path)) {
const auto result = std::filesystem::remove(full_path, ec);
if (ec) {
XELOGE("{}: Cannot remove file entry. File: {} Error: {}", __func__,
full_path, ec.message());
return false;
}
}
return true;
}
}

View File

@@ -51,5 +51,7 @@ X_STATUS NullEntry::Open(uint32_t desired_access, File** out_file) {
return X_STATUS_SUCCESS;
}
bool NullEntry::DeleteEntryInternal(Entry* entry) { return false; }
} // namespace vfs
} // namespace xe

View File

@@ -34,6 +34,8 @@ class NullEntry : public Entry {
private:
friend class NullDevice;
bool DeleteEntryInternal(Entry* entry) override;
};
} // namespace vfs

View File

@@ -42,5 +42,7 @@ X_STATUS XContentContainerEntry::Open(uint32_t desired_access,
return X_STATUS_SUCCESS;
}
bool XContentContainerEntry::DeleteEntryInternal(Entry* entry) { return false; }
} // namespace vfs
} // namespace xe

View File

@@ -51,6 +51,8 @@ class XContentContainerEntry : public Entry {
friend class StfsContainerDevice;
friend class SvodContainerDevice;
bool DeleteEntryInternal(Entry* entry) override;
MultiFileHandles* files_;
size_t data_offset_;
size_t data_size_;

View File

@@ -140,7 +140,7 @@ class Entry {
const std::string_view name, uint32_t attributes) {
return nullptr;
}
virtual bool DeleteEntryInternal(Entry* entry) { return false; }
virtual bool DeleteEntryInternal(Entry* entry) = 0;
virtual void RenameEntryInternal(const std::filesystem::path file_path) {}
xe::global_critical_region global_critical_region_;