OpenCompote.SGA
0.2.0
dotnet add package OpenCompote.SGA --version 0.2.0
NuGet\Install-Package OpenCompote.SGA -Version 0.2.0
<PackageReference Include="OpenCompote.SGA" Version="0.2.0" />
<PackageVersion Include="OpenCompote.SGA" Version="0.2.0" />
<PackageReference Include="OpenCompote.SGA" />
paket add OpenCompote.SGA --version 0.2.0
#r "nuget: OpenCompote.SGA, 0.2.0"
#:package OpenCompote.SGA@0.2.0
#addin nuget:?package=OpenCompote.SGA&version=0.2.0
#tool nuget:?package=OpenCompote.SGA&version=0.2.0
open-compote
A modern C# library for working with Relic Entertainment's .sga archive format. This project provides support for reading and writing SGA archives used in games built using the Essence engine.
About
open-compote is an open-source project aimed at providing mod tools developers and experienced modders with robust and easy to use tools for working with .sga archives. Whether you're developing mods, analyzing game data, or building mod tools, this library offers a simple API for archive manipulation.
Key Features
- Easy to use API — Simple, consistent APIs with, I hope good documentation
- Forward-looking — Comprehensive schema documentation for planned versions (V4, V5, V7)
- Well-documented — Detailed format specifications and examples
Current Status: Beta-stage development. Only SGA V2 is implemented and the package is available on NuGet. If you want support for additional versions early, you can contribute with issues, feature requests, or pull requests. Community contributions are welcome.
Quick start
[!NOTE] For more detailed examples, API reference, and schema specifications, visit our documentation page.
You can download the latest version from the NuGet repo.
dotnet add package OpenCompote.SGA
Reading from SGA archive
This example shows how to open an existing SGA archive and prints its content tree.
using OpenCompote.SGA;
using System.Text;
// Open the archive
using SgaArchive archive = SgaArchiveFile.Open("example.sga", SgaMode.Read);
// prints entire folder structure
foreach (SgaDrive drive in archive.Drives)
{
Console.WriteLine($"Drive: {drive.Name} (alias: {drive.Alias})");
void PrintFolder(SgaFolder folder, int indent)
{
string prefix = new string(' ', indent * 2);
Console.WriteLine($"{prefix}Folder: {folder.Name}");
foreach (SgaEntry entry in folder.Contents)
{
if (entry is SgaFolder subfolder)
{
PrintFolder(subfolder, indent + 1);
}
else if (entry is SgaFile file)
{
Console.WriteLine($"{prefix} File: {file.Name} (size: {file.Size})");
}
}
}
PrintFolder(drive.RootFolder, 0);
}
Quick Links
Supported SGA Versions
| Version | Games | Status | Documentation |
|---|---|---|---|
| V2 | Impossible Creatures,<br> Warhammer 40,000: Dawn of war | SGA-V2.md | |
| V3 | The Outfit | ||
| V4 | Company of Heroes 1 | SGA-V4.md | |
| V5 | Warhammer 40,000: Dawn of War 2 | SGA-V5.md | |
| V6 | Can be created using Company of Heroes 2 archive.exe. | ||
| V7 | Company of Heroes 2 | SGA-V7.md | |
| V9 | Warhammer 40,000: Dawn of War 3 | ||
| V10 | Age of Empires 4,<br> Company of Heroes 3 |
Extension Methods
The following features are currently not implemented but are planned for future releases.
| Method | Purpose | Status |
|---|---|---|
SgaArchiveFile.CreateFromDirectory(...) |
Create an SGA archive from <br>a filesystem directory | |
SgaArchiveFile.ExtractToDirectory(...) |
Extract an archive to a directory | |
GetEntry(...) |
Locate an entry inside the archive,<br> drive or folder | |
SgaFolder.ExtractToDirectory(...) |
Extract a folder and its contents to disk | |
SgaFile.ExtractToFile(...) |
Extract a single file to disk |
Development
The project is organized as a .NET solution with the following components:
- OpenCompote.SGA — Core library for working with SGA Archives.
- OpenCompote.Cli — Currently only for testing. Command-line tools for simple manipulation with SGA archives.
- tests — Unit tests.
Acknowledgments
Some resources that were useful while researching and implementing this project.
- MAK Relic-Tool – Similar project to this, but made in Python and on top of SGAs it also supports UCS and Chunky files.
- dow_utils – Dawn of War modding tutorials, file extension overview, and tools.
Disclaimer
Not affiliated with Relic Entertainment, Sega, or THQ Nordic. All rights belong to their respective parties.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- System.IO.Hashing (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
### Added
- Added the `SgaFile.ExtractToFile` method.
- Added support for Reading and writing SGA-V2 [file metadata](https://vojcermak.github.io/open-compote/schema/SGA-V2.html#file-metadata).
- Added new `SgaFile` properties:
- `Crc` - Gets the Crc-32 checksum of the file. (Only when supported by archive version.)
- `Modified`- Gets or sets the last write time of the file in the archive.
- Added dependencies:
- System.IO.Hashing - Used for crc-32 calculation.
### Changed
- Added missing input validations and unified exceptions.
- Added missing exception references in the api reference docs.
- Reworked writer API and optimized SGA V2 Parser.
- Reworked tests for core classes.
- Fixed offsets in sga-V2 schema documentation.