mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-29 14:05:17 -04:00
fs.mitm: require less contiguous memory to build romfs
This commit is contained in:
parent
d0404f3cc9
commit
5a15d62b8b
3 changed files with 124 additions and 74 deletions
|
@ -213,4 +213,29 @@ namespace ams::mitm::fs {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result CreateAndOpenAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, size_t size) {
|
||||
R_TRY(EnsureSdInitialized());
|
||||
|
||||
char fixed_path[ams::fs::EntryNameLengthMax + 1];
|
||||
FormatAtmosphereSdPath(fixed_path, sizeof(fixed_path), program_id, path);
|
||||
|
||||
/* Unconditionally create. */
|
||||
/* Don't check error, as a failure here should be okay. */
|
||||
FsFile f;
|
||||
fsFsCreateFile(&g_sd_filesystem, fixed_path, size, 0);
|
||||
|
||||
/* Try to open. */
|
||||
R_TRY(fsFsOpenFile(&g_sd_filesystem, fixed_path, OpenMode_ReadWrite, &f));
|
||||
auto file_guard = SCOPE_GUARD { fsFileClose(&f); };
|
||||
|
||||
/* Try to set the size. */
|
||||
R_TRY(fsFileSetSize(&f, static_cast<s64>(size)));
|
||||
|
||||
/* Set output. */
|
||||
file_guard.Cancel();
|
||||
*out = f;
|
||||
return ResultSuccess();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue