ams: finish stdio -> fs bindings for stratosphere

This commit is contained in:
Michael Scire
2020-03-09 03:58:02 -07:00
parent 237b513408
commit 93004be59e
13 changed files with 67 additions and 58 deletions

View File

@@ -22,7 +22,6 @@ extern "C" {
u32 __nx_applet_type = AppletType_None;
u32 __nx_fs_num_sessions = 1;
u32 __nx_fsdev_direntry_cache_size = 1;
#define INNER_HEAP_SIZE 0x1000000
size_t nx_inner_heap_size = INNER_HEAP_SIZE;

View File

@@ -85,7 +85,7 @@ namespace ams::mitm::fs {
const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(&sd_fs.s)};
std::unique_ptr<fs::fsa::IFileSystem> sd_ifs = std::make_unique<fs::RemoteFileSystem>(sd_fs);
out.SetValue(std::make_shared<IFileSystemInterface>(std::make_shared<fs::ReadOnlyFileSystemAdapter>(std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(sd_ifs), AtmosphereHblWebContentDir)), false), target_object_id);
out.SetValue(std::make_shared<IFileSystemInterface>(std::make_shared<fs::ReadOnlyFileSystem>(std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(sd_ifs), AtmosphereHblWebContentDir)), false), target_object_id);
return ResultSuccess();
}
@@ -126,7 +126,7 @@ namespace ams::mitm::fs {
new_fs = std::make_shared<ReadOnlyLayeredFileSystem>(std::move(subdir_fs), std::make_unique<fs::RemoteFileSystem>(base_fs));
} else {
/* Without an existing FS, just make a read only adapter to the subdirectory. */
new_fs = std::make_shared<fs::ReadOnlyFileSystemAdapter>(std::move(subdir_fs));
new_fs = std::make_shared<fs::ReadOnlyFileSystem>(std::move(subdir_fs));
}
out.SetValue(std::make_shared<IFileSystemInterface>(std::move(new_fs), false), target_object_id);
@@ -220,7 +220,7 @@ namespace ams::mitm::fs {
}
/* Ensure the directory exists. */
R_TRY(fssystem::EnsureDirectoryExistsRecursively(sd_ifs.get(), save_dir_path));
R_TRY(fssystem::EnsureDirectoryRecursively(sd_ifs.get(), save_dir_path));
/* Create directory savedata filesystem. */
std::unique_ptr<fs::fsa::IFileSystem> subdir_fs = std::make_unique<fssystem::SubDirectoryFileSystem>(sd_ifs, save_dir_path);

View File

@@ -20,8 +20,8 @@ namespace ams::mitm::fs {
class ReadOnlyLayeredFileSystem : public ams::fs::fsa::IFileSystem {
private:
ams::fs::ReadOnlyFileSystemAdapter fs_1;
ams::fs::ReadOnlyFileSystemAdapter fs_2;
ams::fs::ReadOnlyFileSystem fs_1;
ams::fs::ReadOnlyFileSystem fs_2;
public:
explicit ReadOnlyLayeredFileSystem(std::unique_ptr<ams::fs::fsa::IFileSystem> a, std::unique_ptr<ams::fs::fsa::IFileSystem> b) : fs_1(std::move(a)), fs_2(std::move(b)) { /* ... */ }

View File

@@ -290,15 +290,17 @@ namespace ams::settings::fwdbg {
Result LoadSdCardKeyValueStore() {
/* Open file. */
FsFile config_file;
if (R_FAILED(ams::mitm::fs::OpenAtmosphereSdFile(&config_file, "/config/system_settings.ini", fs::OpenMode_Read))) {
/* It's okay if the file isn't readable/present, because we already loaded defaults. */
return ResultSuccess();
/* It's okay if the file isn't readable/present, because we already loaded defaults. */
std::unique_ptr<ams::fs::fsa::IFile> file;
{
FsFile f;
R_SUCCEED_IF(R_FAILED(ams::mitm::fs::OpenAtmosphereSdFile(std::addressof(f), "/config/system_settings.ini", fs::OpenMode_Read)));
file = std::make_unique<ams::fs::RemoteFile>(f);
}
ON_SCOPE_EXIT { fsFileClose(&config_file); };
AMS_ABORT_UNLESS(file != nullptr);
Result parse_result = ResultSuccess();
util::ini::ParseFile(&config_file, &parse_result, SystemSettingsIniHandler);
util::ini::ParseFile(file.get(), &parse_result, SystemSettingsIniHandler);
R_TRY(parse_result);
return ResultSuccess();