War3Net.IO.Mpq 6.0.2

dotnet add package War3Net.IO.Mpq --version 6.0.2
                    
NuGet\Install-Package War3Net.IO.Mpq -Version 6.0.2
                    
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="War3Net.IO.Mpq" Version="6.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="War3Net.IO.Mpq" Version="6.0.2" />
                    
Directory.Packages.props
<PackageReference Include="War3Net.IO.Mpq" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add War3Net.IO.Mpq --version 6.0.2
                    
#r "nuget: War3Net.IO.Mpq, 6.0.2"
                    
#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.
#:package War3Net.IO.Mpq@6.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=War3Net.IO.Mpq&version=6.0.2
                    
Install as a Cake Addin
#tool nuget:?package=War3Net.IO.Mpq&version=6.0.2
                    
Install as a Cake Tool

War3Net.IO.Mpq

About

War3Net.IO.Mpq is a .NET library for reading and writing MPQ (MoPaQ) archives, a container format used by Blizzard games including Warcraft III. It is part of the War3Net modding library.

Key features

  • Open and read files from existing MPQ archives
  • Create new MPQ archives with customizable options
  • Modify existing archives by adding or removing files
  • Support for file compression (ZLib, PKLib, BZip2, LZMA)
  • Support for file encryption with automatic seed calculation
  • Handle multiple file locales within the same archive
  • Access files in nested archives (archives within archives)
  • Automatic listfile and attributes management

How to Use

Read files from an archive

using War3Net.IO.Mpq;

// Open an existing archive
using var archive = MpqArchive.Open("path/to/archive.mpq", loadListFile: true);

// Check if a file exists
if (archive.FileExists("war3map.w3i"))
{
    // Open and read a file
    using var stream = archive.OpenFile("war3map.w3i");
    // Process the stream...
}

Create a new archive

using War3Net.IO.Mpq;

// Create files to add to the archive
var file1 = MpqFile.New(File.OpenRead("script.j"), "war3map.j");
var file2 = MpqFile.New(new MemoryStream(data), "war3map.w3i");

// Configure archive options
var options = new MpqArchiveCreateOptions
{
    BlockSize = 3,
    HashTableSize = 16,
    ListFileCreateMode = MpqFileCreateMode.Overwrite,
    AttributesCreateMode = MpqFileCreateMode.Overwrite,
};

// Create the archive
using var archive = MpqArchive.Create(
    "output.mpq",
    new[] { file1, file2 },
    options);

Modify an existing archive

using War3Net.IO.Mpq;

// Open the original archive
using var archive = MpqArchive.Open("map.w3x", loadListFile: true);

// Create a builder from the archive
var builder = new MpqArchiveBuilder(archive);

// Add a new file
var newFile = MpqFile.New(new MemoryStream(newData), "newfile.txt");
builder.AddFile(newFile);

// Remove an existing file
builder.RemoveFile("oldfile.txt");

// Save the modified archive
builder.SaveTo("modified.w3x");

Set file compression and encryption

using War3Net.IO.Mpq;

var file = MpqFile.New(stream, "encrypted.dat");

// Set compression type
file.CompressionType = MpqCompressionType.ZLib;

// Set target flags for compression and encryption
file.TargetFlags = MpqFileFlags.Exists
    | MpqFileFlags.CompressedMulti
    | MpqFileFlags.Encrypted;

Main Types

The main types provided by this library are:

  • War3Net.IO.Mpq.MpqArchive - Represents an MPQ archive for reading or creating
  • War3Net.IO.Mpq.MpqArchiveBuilder - Builder for modifying existing archives
  • War3Net.IO.Mpq.MpqArchiveCreateOptions - Configuration options for archive creation
  • War3Net.IO.Mpq.MpqFile - Represents a file to be added to an archive
  • War3Net.IO.Mpq.MpqStream - Stream for reading file contents from an archive
  • War3Net.IO.Mpq.MpqEntry - Metadata entry for a file in the block table
  • War3Net.IO.Mpq.MpqHash - Hash table entry for file lookup
  • War3Net.IO.Mpq.MpqFileFlags - Flags for file compression, encryption, and existence
  • War3Net.IO.Mpq.MpqCompressionType - Compression algorithms (ZLib, PKLib, BZip2, etc.)
  • War3Net.IO.Mpq.MpqLocale - Locale identifiers for multi-language support

Feedback and contributing

War3Net.IO.Mpq is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Disclaimer

This README was generated with the assistance of AI and may contain inaccuracies. Please verify the information and consult the source code for authoritative details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on War3Net.IO.Mpq:

Package Downloads
War3Net.Build.Core

Parsers and serializers for war3map files.

IS4.SFI.Formats.GameArchives

Provides support for old games archive formats.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.2 220 3/1/2026
6.0.1 268 2/1/2026
6.0.0 218 1/25/2026
5.8.1 1,413 9/12/2025
5.8.0 259 9/6/2025
5.6.1 7,906 1/7/2023
5.6.0 1,011 12/20/2022
5.5.5 2,904 11/13/2022
5.5.3 1,249 10/29/2022
5.5.2 1,093 10/25/2022
5.5.0 2,206 8/20/2022
5.4.5 1,457 5/27/2022
5.4.3 2,430 3/20/2022
5.4.0 2,190 2/13/2022
5.3.0 1,503 1/16/2022
5.2.1 583 7/23/2021
5.2.0 584 4/27/2021
5.1.3 2,794 2/14/2021
5.1.2 639 1/9/2021
5.1.1 693 1/1/2021
Loading failed