Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LittlePack is a lightweight C# library for packing and unpacking collections of files into a single compressed byte array.

License

Notifications You must be signed in to change notification settings

waltersoto/littlepack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LittlePack

Version: 2.0.0_Beta This is the second major release of LittlePack, upgraded from .NET 4.0 to .NET 8.0 and rebuilt with full CLI support, encryption, pattern filtering, and test coverage.

LittlePack is a lightweight C# library for packing and unpacking collections of files into a single compressed byte array. It supports GZip compression, relative file path preservation, optional AES encryption, and filtering via wildcards. This library is ideal for bundling files for transport, backup, or use in custom archival formats.


✨ Features

  • Pack and unpack collections of files using a simple Record model
  • Preserves folder structure using relative paths
  • Uses GZip for compression
  • Optional AES encryption using a password
  • Supports file filtering via --ignore, --only, and .littlepackignore patterns
  • Designed for integration into CLI or backend tools

🧰 Usage

Packing Files (from Folder)

var files = Directory.GetFiles("./input", "*", SearchOption.AllDirectories);
var records = files.Select(f => new Record(
    Path.GetRelativePath("./input", f),
    File.ReadAllBytes(f))
).ToList();

var packer = new Packer(records);
var packedBytes = packer.Pack();
File.WriteAllBytes("archive.lpkg", packedBytes);

Manual Packing (Individual Files)

var packer = new Packer();

packer.Records.Add(new Record { FileName = "file1.png", Data = File.ReadAllBytes(@"C:\\Data\\file1.png") });
packer.Records.Add(new Record { FileName = "file2.png", Data = File.ReadAllBytes(@"C:\\Data\\file2.png") });
packer.Records.Add(new Record { FileName = "file3.png", Data = File.ReadAllBytes(@"C:\\Data\\file3.png") });

byte[] package = packer.Pack();
File.WriteAllBytes(@"C:\\Temp\\package.pack", package);

Unpacking Files

var packedBytes = File.ReadAllBytes("archive.lpkg");
var records = Packer.Unpack(packedBytes);
records.SaveTo("./output");

Optional Encryption

// Encrypt
var encrypted = CryptoUtility.Encrypt(packedBytes, "MyPassword");
File.WriteAllBytes("secure.lpkg", encrypted);

// Decrypt
var decrypted = CryptoUtility.Decrypt(File.ReadAllBytes("secure.lpkg"), "MyPassword");
var records = Packer.Unpack(decrypted);

🧪 Testing

Unit tests are included for:

  • Encryption and decryption round-trips
  • Packing/unpacking byte-level consistency
  • CLI argument parsing and pattern filtering

To run tests:

dotnet test

📁 Project Structure

  • Record.cs - Represents a file (name + data)
  • Packer.cs - Handles pack/unpack logic with compression
  • CryptoUtility.cs - AES encryption and decryption helpers
  • LittlePackExtensions.cs - File saving helpers
  • CliParser.cs - CLI argument parsing and .littlepackignore support
  • LittlePackCli.cs - Main runner for CLI mode

📄 License

MIT License. Use it, fork it, break it, fix it — enjoy.

About

LittlePack is a lightweight C# library for packing and unpacking collections of files into a single compressed byte array.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages