SarcLibrary 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SarcLibrary --version 2.0.1
NuGet\Install-Package SarcLibrary -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SarcLibrary" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SarcLibrary --version 2.0.1
#r "nuget: SarcLibrary, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SarcLibrary as a Cake Addin
#addin nuget:?package=SarcLibrary&version=2.0.1

// Install SarcLibrary as a Cake Tool
#tool nuget:?package=SarcLibrary&version=2.0.1

SarcLibrary

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.

Usage

Reading a Sarc File

// 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);

Writing a Sarc File

// 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);

Sarc Tools

// 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)

Benchmarks

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

Byte-Perfect Exceptions

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.<br> 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

NuGet NuGet

NuGet
Install-Package SarcLibrary
Build From Source
git clone https://github.com/NCF-Library/SarcLibrary.git
dotnet build SarcLibrary

Credit

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SarcLibrary:

Package Downloads
TotkCommon

Simple primitives library for common TotK operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.2 158 4/6/2024
3.1.1 102 4/5/2024
3.1.0 113 3/15/2024
3.0.4 256 1/26/2024
3.0.3 88 1/19/2024
3.0.2 102 1/16/2024
3.0.1 87 1/16/2024
3.0.0 158 12/13/2023
2.0.2 573 12/31/2022
2.0.1 265 12/30/2022
2.0.0 270 12/22/2022
1.0.6 445 8/18/2022
1.0.5 437 6/20/2022
1.0.4 403 6/16/2022
1.0.3 396 6/8/2022
1.0.1 387 6/5/2022
1.0.0 389 6/5/2022