Skip to content

Uotan-Dev/FirmwareKit.Sparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FirmwareKit.Sparse

A high-performance .NET library for parsing, editing, and converting Android Sparse images.

NuGet version License: MIT

Installation

dotnet add package FirmwareKit.Sparse

Basic Usage

Reading a Sparse Image

using FirmwareKit.Sparse.Core;
using FirmwareKit.Sparse.Streams;

// Parse a sparse image file
using var sparseFile = SparseFile.FromImageFile("system.simg");

// Access as a read-only Stream
using var stream = new SparseStream(sparseFile);
var buffer = new byte[4096];
stream.Read(buffer, 0, buffer.Length);

Converting Sparse to Raw

using FirmwareKit.Sparse.Utils;

SparseImageConverter.ConvertSparseToRaw(new[] { "system.simg" }, "system.raw.img");

Resparsing (Splitting)

using FirmwareKit.Sparse.Core;
using System.IO;

using var sparseFile = SparseFile.FromImageFile("massive_system.simg");
// Split into multiple sparse files, each max 512MB
var smallerFiles = sparseFile.Resparse(512 * 1024 * 1024);

for (int i = 0; i < smallerFiles.Count; i++)
{
    using var fs = new FileStream($"part_{i}.simg", FileMode.Create);
    smallerFiles[i].WriteToStream(fs);
}

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages