[VFS] Rewrote STFS to use memory mapping
- Replaced old-style buffer, buffer_length with std::span - Added STFS and SVOD specific Entry and File classes - Other smaller improvements
This commit is contained in:
committed by
Radosław Gliński
parent
e85c2392ba
commit
fe739208b6
@@ -202,8 +202,9 @@ bool ProfileManager::LoadAccount(const uint64_t xuid) {
|
||||
file_data.resize(output_file->entry()->size());
|
||||
|
||||
size_t bytes_read = 0;
|
||||
output_file->ReadSync(file_data.data(), output_file->entry()->size(), 0,
|
||||
&bytes_read);
|
||||
output_file->ReadSync(
|
||||
std::span<uint8_t>(file_data.data(), output_file->entry()->size()), 0,
|
||||
&bytes_read);
|
||||
output_file->Destroy();
|
||||
|
||||
if (bytes_read < sizeof(X_XAMACCOUNTINFO)) {
|
||||
@@ -562,8 +563,9 @@ bool ProfileManager::UpdateAccount(const uint64_t xuid,
|
||||
EncryptAccountFile(account, encrypted_data.data());
|
||||
|
||||
size_t written_bytes = 0;
|
||||
output_file->WriteSync(encrypted_data.data(), encrypted_data.size(), 0,
|
||||
&written_bytes);
|
||||
output_file->WriteSync(
|
||||
std::span<uint8_t>(encrypted_data.data(), encrypted_data.size()), 0,
|
||||
&written_bytes);
|
||||
output_file->Destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ void UserProfile::LoadProfileIcon(XTileType tile_type) {
|
||||
|
||||
std::vector<uint8_t> data(file->entry()->size());
|
||||
size_t written_bytes = 0;
|
||||
file->ReadSync(data.data(), file->entry()->size(), 0, &written_bytes);
|
||||
file->ReadSync(std::span<uint8_t>(data.data(), file->entry()->size()), 0,
|
||||
&written_bytes);
|
||||
file->Destroy();
|
||||
|
||||
profile_images_.insert({tile_type, data});
|
||||
@@ -114,7 +115,8 @@ std::vector<uint8_t> UserProfile::LoadGpd(const uint32_t title_id) {
|
||||
std::vector<uint8_t> data(entry->size());
|
||||
|
||||
size_t read_size = 0;
|
||||
result = file->ReadSync(data.data(), entry->size(), 0, &read_size);
|
||||
result = file->ReadSync(std::span<uint8_t>(data.data(), entry->size()), 0,
|
||||
&read_size);
|
||||
if (result != X_STATUS_SUCCESS || read_size != entry->size()) {
|
||||
XELOGW(
|
||||
"User {} (XUID: {:016X}) cannot read profile GPD! Status: {:08X} read: "
|
||||
@@ -150,7 +152,8 @@ bool UserProfile::WriteGpd(const uint32_t title_id) {
|
||||
}
|
||||
|
||||
size_t written_bytes = 0;
|
||||
file->WriteSync(data.data(), data.size(), 0, &written_bytes);
|
||||
file->WriteSync(std::span<uint8_t>(data.data(), data.size()), 0,
|
||||
&written_bytes);
|
||||
file->Destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user