ams: replace most remaining operator & with std::addressof
This commit is contained in:
@@ -116,7 +116,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
bool GetSettingsItemBooleanValue(const char *name, const char *key) {
|
||||
u8 tmp = 0;
|
||||
AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValue(&tmp, sizeof(tmp), name, key) == sizeof(tmp));
|
||||
AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValue(std::addressof(tmp), sizeof(tmp), name, key) == sizeof(tmp));
|
||||
return (tmp != 0);
|
||||
}
|
||||
|
||||
@@ -133,20 +133,20 @@ namespace ams::mitm::fs {
|
||||
Result OpenHblWebContentFileSystem(sf::Out<sf::SharedPointer<ams::fssrv::sf::IFileSystem>> &out, ncm::ProgramId program_id) {
|
||||
/* Verify eligibility. */
|
||||
bool is_hbl;
|
||||
R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession());
|
||||
R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), program_id)), sm::mitm::ResultShouldForwardToSession());
|
||||
R_UNLESS(is_hbl, sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
/* Hbl html directory must exist. */
|
||||
{
|
||||
FsDir d;
|
||||
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(&d, AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
|
||||
fsDirClose(&d);
|
||||
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenSdDirectory(std::addressof(d), AtmosphereHblWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
|
||||
fsDirClose(std::addressof(d));
|
||||
}
|
||||
|
||||
/* Open the SD card using fs.mitm's session. */
|
||||
FsFileSystem sd_fs;
|
||||
R_TRY(fsOpenSdCardFileSystem(&sd_fs));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
|
||||
R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
|
||||
std::unique_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_unique<fs::RemoteFileSystem>(sd_fs);
|
||||
|
||||
out.SetValue(MakeSharedFileSystem(std::make_shared<fs::ReadOnlyFileSystem>(std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(sd_ifs), AtmosphereHblWebContentDir)), false), target_object_id);
|
||||
@@ -157,14 +157,14 @@ namespace ams::mitm::fs {
|
||||
/* Directory must exist. */
|
||||
{
|
||||
FsDir d;
|
||||
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(&d, program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
|
||||
fsDirClose(&d);
|
||||
R_UNLESS(R_SUCCEEDED(mitm::fs::OpenAtmosphereSdDirectory(std::addressof(d), program_id, ProgramWebContentDir, fs::OpenDirectoryMode_Directory)), sm::mitm::ResultShouldForwardToSession());
|
||||
fsDirClose(std::addressof(d));
|
||||
}
|
||||
|
||||
/* Open the SD card using fs.mitm's session. */
|
||||
FsFileSystem sd_fs;
|
||||
R_TRY(fsOpenSdCardFileSystem(&sd_fs));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
|
||||
R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
|
||||
std::unique_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_unique<fs::RemoteFileSystem>(sd_fs);
|
||||
|
||||
/* Format the subdirectory path. */
|
||||
@@ -231,8 +231,8 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Create a new SD card filesystem. */
|
||||
FsFileSystem sd_fs;
|
||||
R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), &sd_fs));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
|
||||
R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), std::addressof(sd_fs)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
|
||||
|
||||
/* Return output filesystem. */
|
||||
std::shared_ptr<fs::fsa::IFileSystem> redir_fs = std::make_shared<fssystem::DirectoryRedirectionFileSystem>(std::make_shared<RemoteFileSystem>(sd_fs), "/Nintendo", emummc::GetNintendoDirPath());
|
||||
@@ -260,13 +260,13 @@ namespace ams::mitm::fs {
|
||||
/* Verify we can open the save. */
|
||||
static_assert(sizeof(fs::SaveDataAttribute) == sizeof(::FsSaveDataAttribute));
|
||||
FsFileSystem save_fs;
|
||||
R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), &save_fs, space_id, reinterpret_cast<const FsSaveDataAttribute *>(&attribute))), sm::mitm::ResultShouldForwardToSession());
|
||||
R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), std::addressof(save_fs), space_id, reinterpret_cast<const FsSaveDataAttribute *>(std::addressof(attribute)))), sm::mitm::ResultShouldForwardToSession());
|
||||
std::unique_ptr<fs::fsa::IFileSystem> save_ifs = std::make_unique<fs::RemoteFileSystem>(save_fs);
|
||||
|
||||
/* Mount the SD card using fs.mitm's session. */
|
||||
FsFileSystem sd_fs;
|
||||
R_TRY(fsOpenSdCardFileSystem(&sd_fs));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
|
||||
R_TRY(fsOpenSdCardFileSystem(std::addressof(sd_fs)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))};
|
||||
std::shared_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_shared<fs::RemoteFileSystem>(sd_fs);
|
||||
|
||||
/* Verify that we can open the save directory, and that it exists. */
|
||||
@@ -278,7 +278,7 @@ namespace ams::mitm::fs {
|
||||
bool is_new_save = false;
|
||||
{
|
||||
fs::DirectoryEntryType ent;
|
||||
R_TRY_CATCH(sd_ifs->GetEntryType(&ent, save_dir_path)) {
|
||||
R_TRY_CATCH(sd_ifs->GetEntryType(std::addressof(ent), save_dir_path)) {
|
||||
R_CATCH(fs::ResultPathNotFound) { is_new_save = true; }
|
||||
R_CATCH_ALL() { /* ... */ }
|
||||
} R_END_TRY_CATCH;
|
||||
@@ -310,8 +310,8 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Try to open a storage for the partition. */
|
||||
FsStorage bis_storage;
|
||||
R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&bis_storage.s)};
|
||||
R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), std::addressof(bis_storage), bis_partition_id));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(bis_storage.s))};
|
||||
|
||||
const bool is_sysmodule = ncm::IsSystemProgramId(this->client_info.program_id);
|
||||
const bool is_hbl = this->client_info.override_status.IsHbl();
|
||||
@@ -355,8 +355,8 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Try to open the process romfs. */
|
||||
FsStorage data_storage;
|
||||
R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), &data_storage));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)};
|
||||
R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), std::addressof(data_storage)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))};
|
||||
|
||||
/* Get a scoped lock. */
|
||||
std::scoped_lock lk(g_data_storage_lock);
|
||||
@@ -376,7 +376,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Create the layered storage. */
|
||||
FsFile data_file;
|
||||
if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, this->client_info.program_id, "romfs.bin", OpenMode_Read))) {
|
||||
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), this->client_info.program_id, "romfs.bin", OpenMode_Read))) {
|
||||
auto layered_storage = std::make_shared<LayeredRomfsStorage>(std::make_unique<ReadOnlyStorageAdapter>(new RemoteStorage(data_storage)), std::make_unique<ReadOnlyStorageAdapter>(new FileStorage(new RemoteFile(data_file))), this->client_info.program_id);
|
||||
layered_storage->BeginInitialize();
|
||||
new_storage = std::move(layered_storage);
|
||||
@@ -386,7 +386,7 @@ namespace ams::mitm::fs {
|
||||
new_storage = std::move(layered_storage);
|
||||
}
|
||||
|
||||
SetStorageCacheEntry(this->client_info.program_id, &new_storage);
|
||||
SetStorageCacheEntry(this->client_info.program_id, std::addressof(new_storage));
|
||||
out.SetValue(MakeSharedStorage(new_storage), target_object_id);
|
||||
}
|
||||
|
||||
@@ -405,8 +405,8 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Try to open the process romfs. */
|
||||
FsStorage data_storage;
|
||||
R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), &data_storage, static_cast<u64>(data_id), static_cast<NcmStorageId>(storage_id)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)};
|
||||
R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), std::addressof(data_storage), static_cast<u64>(data_id), static_cast<NcmStorageId>(storage_id)));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))};
|
||||
|
||||
/* Get a scoped lock. */
|
||||
std::scoped_lock lk(g_data_storage_lock);
|
||||
@@ -426,7 +426,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Create the layered storage. */
|
||||
FsFile data_file;
|
||||
if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, data_id, "romfs.bin", OpenMode_Read))) {
|
||||
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), data_id, "romfs.bin", OpenMode_Read))) {
|
||||
auto layered_storage = std::make_shared<LayeredRomfsStorage>(std::make_unique<ReadOnlyStorageAdapter>(new RemoteStorage(data_storage)), std::make_unique<ReadOnlyStorageAdapter>(new FileStorage(new RemoteFile(data_file))), data_id);
|
||||
layered_storage->BeginInitialize();
|
||||
new_storage = std::move(layered_storage);
|
||||
@@ -436,7 +436,7 @@ namespace ams::mitm::fs {
|
||||
new_storage = std::move(layered_storage);
|
||||
}
|
||||
|
||||
SetStorageCacheEntry(data_id, &new_storage);
|
||||
SetStorageCacheEntry(data_id, std::addressof(new_storage));
|
||||
out.SetValue(MakeSharedStorage(new_storage), target_object_id);
|
||||
}
|
||||
|
||||
@@ -456,8 +456,8 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Try to open the process romfs. */
|
||||
FsStorage data_storage;
|
||||
R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), &data_storage, program_index));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&data_storage.s)};
|
||||
R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), std::addressof(data_storage), program_index));
|
||||
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))};
|
||||
|
||||
/* Get a scoped lock. */
|
||||
std::scoped_lock lk(g_data_storage_lock);
|
||||
@@ -477,7 +477,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Create the layered storage. */
|
||||
FsFile data_file;
|
||||
if (R_SUCCEEDED(OpenAtmosphereSdFile(&data_file, program_id, "romfs.bin", OpenMode_Read))) {
|
||||
if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), program_id, "romfs.bin", OpenMode_Read))) {
|
||||
auto layered_storage = std::make_shared<LayeredRomfsStorage>(std::make_unique<ReadOnlyStorageAdapter>(new RemoteStorage(data_storage)), std::make_unique<ReadOnlyStorageAdapter>(new FileStorage(new RemoteFile(data_file))), program_id);
|
||||
layered_storage->BeginInitialize();
|
||||
new_storage = std::move(layered_storage);
|
||||
@@ -487,7 +487,7 @@ namespace ams::mitm::fs {
|
||||
new_storage = std::move(layered_storage);
|
||||
}
|
||||
|
||||
SetStorageCacheEntry(program_id, &new_storage);
|
||||
SetStorageCacheEntry(program_id, std::addressof(new_storage));
|
||||
out.SetValue(MakeSharedStorage(new_storage), target_object_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ams::mitm::fs {
|
||||
void RomfsInitializerThreadFunction(void *) {
|
||||
while (true) {
|
||||
uintptr_t storage_uptr = 0;
|
||||
g_req_mq.Receive(&storage_uptr);
|
||||
g_req_mq.Receive(std::addressof(storage_uptr));
|
||||
std::shared_ptr<LayeredRomfsStorage> layered_storage = reinterpret_cast<LayeredRomfsStorage *>(storage_uptr)->GetShared();
|
||||
g_ack_mq.Send(storage_uptr);
|
||||
layered_storage->InitializeImpl();
|
||||
@@ -54,7 +54,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
g_req_mq.Send(storage_uptr);
|
||||
uintptr_t ack = 0;
|
||||
g_ack_mq.Receive(&ack);
|
||||
g_ack_mq.Receive(std::addressof(ack));
|
||||
AMS_ABORT_UNLESS(ack == storage_uptr);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace ams::mitm::fs {
|
||||
builder.AddStorageFiles(this->storage_romfs.get(), romfs::DataSourceType::Storage);
|
||||
}
|
||||
|
||||
builder.Build(&this->source_infos);
|
||||
builder.Build(std::addressof(this->source_infos));
|
||||
|
||||
this->is_initialized = true;
|
||||
this->initialize_event.Signal();
|
||||
@@ -140,11 +140,11 @@ namespace ams::mitm::fs {
|
||||
case romfs::DataSourceType::LooseSdFile:
|
||||
{
|
||||
FsFile file;
|
||||
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(&file, this->program_id, cur_source.loose_source_info.path, OpenMode_Read));
|
||||
ON_SCOPE_EXIT { fsFileClose(&file); };
|
||||
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(std::addressof(file), this->program_id, cur_source.loose_source_info.path, OpenMode_Read));
|
||||
ON_SCOPE_EXIT { fsFileClose(std::addressof(file)); };
|
||||
|
||||
u64 out_read = 0;
|
||||
R_ABORT_UNLESS(fsFileRead(&file, offset_within_source, cur_dst, cur_read_size, FsReadOption_None, &out_read));
|
||||
R_ABORT_UNLESS(fsFileRead(std::addressof(file), offset_within_source, cur_dst, cur_read_size, FsReadOption_None, std::addressof(out_read)));
|
||||
AMS_ABORT_UNLESS(out_read == cur_read_size);
|
||||
}
|
||||
break;
|
||||
@@ -154,7 +154,7 @@ namespace ams::mitm::fs {
|
||||
case romfs::DataSourceType::Metadata:
|
||||
{
|
||||
size_t out_read = 0;
|
||||
R_ABORT_UNLESS(cur_source.metadata_source_info.file->Read(&out_read, offset_within_source, cur_dst, cur_read_size));
|
||||
R_ABORT_UNLESS(cur_source.metadata_source_info.file->Read(std::addressof(out_read), offset_within_source, cur_dst, cur_read_size));
|
||||
AMS_ABORT_UNLESS(out_read == cur_read_size);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace ams::mitm::fs {
|
||||
private:
|
||||
ALWAYS_INLINE void Read(size_t ofs, void *dst, size_t sz) {
|
||||
u64 read_size;
|
||||
R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, &read_size));
|
||||
R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, std::addressof(read_size)));
|
||||
AMS_ABORT_UNLESS(read_size == sz);
|
||||
}
|
||||
|
||||
@@ -317,9 +317,9 @@ namespace ams::mitm::fs {
|
||||
/* Get number of child directories. */
|
||||
s64 num_child_dirs = 0;
|
||||
{
|
||||
OpenFileSystemRomfsDirectory(&dir, this->program_id, parent, OpenDirectoryMode_Directory, fs);
|
||||
ON_SCOPE_EXIT { fsDirClose(&dir); };
|
||||
R_ABORT_UNLESS(fsDirGetEntryCount(&dir, &num_child_dirs));
|
||||
OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_Directory, fs);
|
||||
ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); };
|
||||
R_ABORT_UNLESS(fsDirGetEntryCount(std::addressof(dir), std::addressof(num_child_dirs)));
|
||||
}
|
||||
AMS_ABORT_UNLESS(num_child_dirs >= 0);
|
||||
|
||||
@@ -330,12 +330,12 @@ namespace ams::mitm::fs {
|
||||
|
||||
s64 cur_child_dir_ind = 0;
|
||||
{
|
||||
OpenFileSystemRomfsDirectory(&dir, this->program_id, parent, OpenDirectoryMode_All, fs);
|
||||
ON_SCOPE_EXIT { fsDirClose(&dir); };
|
||||
OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_All, fs);
|
||||
ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); };
|
||||
|
||||
s64 read_entries = 0;
|
||||
while (true) {
|
||||
R_ABORT_UNLESS(fsDirRead(&dir, &read_entries, 1, &this->dir_entry));
|
||||
R_ABORT_UNLESS(fsDirRead(std::addressof(dir), std::addressof(read_entries), 1, std::addressof(this->dir_entry)));
|
||||
if (read_entries != 1) {
|
||||
break;
|
||||
}
|
||||
@@ -345,7 +345,7 @@ namespace ams::mitm::fs {
|
||||
AMS_ABORT_UNLESS(child_dirs != nullptr);
|
||||
|
||||
BuildDirectoryContext *real_child = nullptr;
|
||||
this->AddDirectory(&real_child, parent, std::make_unique<BuildDirectoryContext>(this->dir_entry.name, strlen(this->dir_entry.name)));
|
||||
this->AddDirectory(std::addressof(real_child), parent, std::make_unique<BuildDirectoryContext>(this->dir_entry.name, strlen(this->dir_entry.name)));
|
||||
AMS_ABORT_UNLESS(real_child != nullptr);
|
||||
child_dirs[cur_child_dir_ind++] = real_child;
|
||||
AMS_ABORT_UNLESS(cur_child_dir_ind <= num_child_dirs);
|
||||
@@ -392,7 +392,7 @@ namespace ams::mitm::fs {
|
||||
{
|
||||
const DirectoryEntry *cur_child = dir_table.GetEntry(cur_child_offset);
|
||||
|
||||
this->AddDirectory(&real_child, parent, std::make_unique<BuildDirectoryContext>(cur_child->name, cur_child->name_size));
|
||||
this->AddDirectory(std::addressof(real_child), parent, std::make_unique<BuildDirectoryContext>(cur_child->name, cur_child->name_size));
|
||||
AMS_ABORT_UNLESS(real_child != nullptr);
|
||||
|
||||
next_child_offset = cur_child->sibling;
|
||||
@@ -409,25 +409,25 @@ namespace ams::mitm::fs {
|
||||
void Builder::AddSdFiles() {
|
||||
/* Open Sd Card filesystem. */
|
||||
FsFileSystem sd_filesystem;
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&sd_filesystem));
|
||||
ON_SCOPE_EXIT { fsFsClose(&sd_filesystem); };
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(sd_filesystem)));
|
||||
ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); };
|
||||
|
||||
/* If there is no romfs folder on the SD, don't bother continuing. */
|
||||
{
|
||||
FsDir dir;
|
||||
if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(&dir, this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, &sd_filesystem))) {
|
||||
if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(std::addressof(dir), this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, std::addressof(sd_filesystem)))) {
|
||||
return;
|
||||
}
|
||||
fsDirClose(&dir);
|
||||
fsDirClose(std::addressof(dir));
|
||||
}
|
||||
|
||||
this->cur_source_type = DataSourceType::LooseSdFile;
|
||||
this->VisitDirectory(&sd_filesystem, this->root);
|
||||
this->VisitDirectory(std::addressof(sd_filesystem), this->root);
|
||||
}
|
||||
|
||||
void Builder::AddStorageFiles(ams::fs::IStorage *storage, DataSourceType source_type) {
|
||||
Header header;
|
||||
R_ABORT_UNLESS(storage->Read(0, &header, sizeof(Header)));
|
||||
R_ABORT_UNLESS(storage->Read(0, std::addressof(header), sizeof(Header)));
|
||||
AMS_ABORT_UNLESS(header.header_size == sizeof(Header));
|
||||
|
||||
/* Read tables. */
|
||||
@@ -444,8 +444,8 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Open an SD card filesystem. */
|
||||
FsFileSystem sd_filesystem;
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(&sd_filesystem));
|
||||
ON_SCOPE_EXIT { fsFsClose(&sd_filesystem); };
|
||||
R_ABORT_UNLESS(fsOpenSdCardFileSystem(std::addressof(sd_filesystem)));
|
||||
ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); };
|
||||
|
||||
/* Calculate hash table sizes. */
|
||||
const size_t num_dir_hash_table_entries = GetHashTableSize(this->num_dirs);
|
||||
@@ -460,7 +460,7 @@ namespace ams::mitm::fs {
|
||||
/* Open metadata file. */
|
||||
const size_t metadata_size = this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size + this->file_table_size;
|
||||
FsFile metadata_file;
|
||||
R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(&metadata_file, this->program_id, "romfs_metadata.bin", metadata_size));
|
||||
R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(std::addressof(metadata_file), this->program_id, "romfs_metadata.bin", metadata_size));
|
||||
|
||||
/* Ensure later hash tables will have correct defaults. */
|
||||
static_assert(EmptyEntry == 0xFFFFFFFF);
|
||||
@@ -534,13 +534,13 @@ namespace ams::mitm::fs {
|
||||
u32 *file_hash_table = reinterpret_cast<u32 *>(fht_buf);
|
||||
std::memset(file_hash_table, 0xFF, this->file_hash_table_size);
|
||||
ON_SCOPE_EXIT {
|
||||
R_ABORT_UNLESS(fsFileWrite(&metadata_file, this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None));
|
||||
R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None));
|
||||
std::free(fht_buf);
|
||||
};
|
||||
|
||||
/* Write the file table. */
|
||||
{
|
||||
FileTableWriter file_table(&metadata_file, this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size);
|
||||
FileTableWriter file_table(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size);
|
||||
|
||||
for (const auto &it : this->files) {
|
||||
BuildFileContext *cur_file = it.get();
|
||||
@@ -602,13 +602,13 @@ namespace ams::mitm::fs {
|
||||
u32 *dir_hash_table = reinterpret_cast<u32 *>(dht_buf);
|
||||
std::memset(dir_hash_table, 0xFF, this->dir_hash_table_size);
|
||||
ON_SCOPE_EXIT {
|
||||
R_ABORT_UNLESS(fsFileWrite(&metadata_file, 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None));
|
||||
R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None));
|
||||
std::free(dht_buf);
|
||||
};
|
||||
|
||||
/* Write the file table. */
|
||||
{
|
||||
DirectoryTableWriter dir_table(&metadata_file, this->dir_hash_table_size, this->dir_table_size);
|
||||
DirectoryTableWriter dir_table(std::addressof(metadata_file), this->dir_hash_table_size, this->dir_table_size);
|
||||
|
||||
for (const auto &it : this->directories) {
|
||||
BuildDirectoryContext *cur_dir = it.get();
|
||||
@@ -657,7 +657,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
/* Save metadata to the SD card, to save on memory space. */
|
||||
{
|
||||
R_ABORT_UNLESS(fsFileFlush(&metadata_file));
|
||||
R_ABORT_UNLESS(fsFileFlush(std::addressof(metadata_file)));
|
||||
out_infos->emplace_back(header->dir_hash_table_ofs, metadata_size, DataSourceType::Metadata, new RemoteFile(metadata_file));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user