Thealexbarney / LibHac

A library that reimplements parts of the Nintendo Switch OS
Other
397 stars 50 forks source link

Help efficiently replacing an NCA in an NSP #310

Closed emargee closed 3 months ago

emargee commented 3 months ago

This is not a bug just a request for some usage help :)

I am experimenting implementing a C# version of uncompressing NCZ -> NCA inside a NSZ(NSP).

I have it working and can decompress the NCZ and create the original NCA .. I can then insert it into a new NSP (with all of the other files) using the PartitionStorageBuilder.

To do this I have to create the NCA file on my local filesystem first (as obviously keeping in memory is not an option).

I was wondering if there was any way to stream the conversion instead of having to go via the filesystem. There are lot of IFile and IStorage options and hoped you might be able to give any pointers if this is even possible :)

Thealexbarney commented 3 months ago

PartitionFileSystemBuilder has a two constructors. The one that takes an IFileSystem will populate the builder with all the files in the file system. The parameterless one creates an builder without any files. In both cases you can call AddFile(string filename, IFile file) to add a file to the builder.

It'll be up to you to use or create an IFile that'll avoid needing to write temporary data to disk.

emargee commented 3 months ago

I implemented my own IFile that handles the decompression on the DoRead and its working great (so far). Thanks for the hint.