Nintendo SEAD Archive Library | Based on oead/sarc by Léo Lam
SarcLibrary has been tested to parse and re-write (almost) every SARC file found in Breath of the Wild byte-perfectly.
// Read from File Path
SarcFile sarc = SarcFile.FromBinary("content/Pack/Bootup.pack");
// Read from a byte[]
// Do not use with File.ReadAllBytes(), use
// a Stream instead.
SarcFile sarc = SarcFile.FromBinary("content/Pack/Bootup.pack");
byte[] decompressedData = Yaz0.Decompress(sarc["GameData/gamedata.ssarc"]);
SarcFile nestedSarc = SarcFile.FromBinary(decompressedData);
// Read from a Stream
using FileStream fs = File.OpenRead("content/Pack/Bootup.pack");
SarcFile sarc = new(fs);
// Write to a File
sarc.ToBinary("content/Pack/Bootup.pack");
// Write to a byte[]
byte[] data = sarc.ToBinary();
// Write to a Stream
using MemoryStream ms = new();
sarc.ToBinary(ms);
// Extract to a Directory
await sarc.ExtractTodirectory("path/to/output");
// Load from a Directory
SarcFile sarc = SarcFile.LoadFromDirectory("path/to/input", searchPattern: "*.*", searchOption: SearchOption.AllDirectories)
Function | Elapsed | Allocated |
---|---|---|
Read TitleBG (75MB, BigEndian) | 29.16 ms | 75,307 KB |
Read TitleBG (143MB. LittleEndian) | 51.02 ms | 143,854 KB |
Write TitleBG (75MB, BigEndian) | 40.90 ms | 110 KB |
Write TitleBG (143MB, LittleEndian) | 127.49 ms | 110 KB |
Extract TitleBG (75MB, BigEndian) | 133.18 ms | 732 KB |
Extract TitleBG (143MB, LittleEndian) | 170.64 ms | 726 KB |
Load from Folder (409 Files, ~73MB) | 40.61 ms | 73,365 KB |
Load from Folder (409 Files, ~140MB) | 68.11 ms | 143,910 KB |
Benchmarks run on an AMD Ryzen 7 3700X
CPU, 64GB (4 x 16GB) of VENGEANCE® DDR4 DRAM 3200MHz C16
memory, and a Kingston KC3000 PCIe 4.0 NVMe M.2
SSD
Exceptions to every file being parsed and re-written byte-perfectly are a the sbeventpack archives in content/Event
, which seems to use a mix of alignments. During tests, I found offsets of 0x100 and 0x8 that had varying reliability.
These odd occurrences are also ignored in oead/sarc
. Luckily, the game does not seem to care if these files are aligned to 4-bytes, so the error is not detrimental (at least not in BOTW).
Install-Package SarcLibrary
git clone https://github.com/NCF-Library/SarcLibrary.git
dotnet build SarcLibrary
- ArchLeaders: Optimized C# SARC implementation based on oead by Léo Lam
- exelix: Original C# SARC implementation
- Léo Lam: C++ SARC implementation