Commit Graph

11 Commits

Author SHA1 Message Date
281f2926bb common/fileutil: Convert namespace to Common::FS
Migrates a remaining common file over to the Common namespace, making it
consistent with the rest of common files.

This also allows for high-traffic FS related code to alias the
filesystem function namespace as

namespace FS = Common::FS;

for more concise typing.
2022-10-30 21:03:49 +02:00
faf9162dbd layered_fs: Make LoadFile and LoadDirectory less recursive
The deep recursion has caused issues in certain games with large numbers of files, especially with MSVC builds.

Previously the recursion depth is about equal to the number of files present. With this the depth should be about equal to the maximum depth of the directory structure of the RomFS.
2020-10-01 00:32:40 +08:00
37a6ea72e5 layered_fs: Mark functions as static where applicable
Makes them internally linked and prevents potential
-Wmissing-declaration warnings.
2020-05-01 09:35:59 -04:00
232b52a27d Minor cleanup 2020-03-28 09:59:45 +00:00
5604613642 More merge fixes 2020-03-27 21:48:58 +00:00
8eacfceb6a layered_fs: Fix missing file size update
This was a silly typo from a previous change.
2020-02-23 15:22:41 +08:00
d9ae4c332d layered_fs: Do not open all replacement files on load
Instead open them when we want to read them. This is because the standard library has a limit on the number of opened files.
2020-02-09 21:48:42 +08:00
13e2d534e9 core: Add dump RomFS support
This is added to LayeredFS, then the NCCH container and then the loader interface.
2020-02-09 20:59:31 +08:00
db18f6c79a Address review
simplify code
2020-02-07 23:53:00 +08:00
6e0afbaa19 Fix build
Explicitly use `std::min<std::size_t>`

Added virtual destructor
2020-02-07 16:26:33 +08:00
890405bb7c core/file_sys: LayeredFS implementation
This implementation is different from Luma3DS's which directly hooks the SDK functions. Instead, we read the RomFS's metadata and figure out the directory and file structure. Then, relocations (i.e. replacements/deletions/patches) are applied. Afterwards, we rebuild the metadata, and assign 'fake' data offsets to the files. When we want to read file data from this rebuilt RomFS, we use binary search to find the last data offset smaller or equal to the given offset and read from that file  (either from the original RomFS, or from replacement files, or from buffered data with patches applied) and any later files when length is not enough.

The code that rebuilds the metadata is pretty complex and uses quite a few variables to keep track of necessary information like metadata offsets. According to my tests, it is able to build RomFS-es identical to the original (but without trailing garbage data) when no relocations are applied.
2020-02-07 15:19:57 +08:00