mpq

package
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2022 License: MPL-2.0 Imports: 6 Imported by: 6

Documentation

Overview

Package mpq provides golang bindings to the StormLib library to read MPQ archives.

Example
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/nielsAD/gowarcraft3/file/mpq"
)

func main() {
	archive, err := mpq.OpenArchive("./test.mpq")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer archive.Close()

	hello, err := archive.Open("hello.txt")
	if err != nil {
		fmt.Println(err)
		return
	}

	raw, err := ioutil.ReadAll(hello)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Print(string(raw))

}
Output:

Hello

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrBadFormat    = errors.New("mpq: Bad format")
	ErrArchiveOpen  = errors.New("mpq: Could not open archive")
	ErrArchiveClose = errors.New("mpq: Could not close archive")
	ErrFileOpen     = errors.New("mpq: Could not open subfile")
	ErrFileClose    = errors.New("mpq: Could not close subfile")
	ErrFileRead     = errors.New("mpq: Could not read subfile")
)

Errors

Functions

This section is empty.

Types

type Archive

type Archive struct {
	// contains filtered or unexported fields
}

Archive stores a handle to an opened MPQ archive

func OpenArchive

func OpenArchive(fileName string) (*Archive, error)

OpenArchive opens fileName as MPQ archive

func (*Archive) Close

func (a *Archive) Close() error

Close an MPQ archive

func (*Archive) Open

func (a *Archive) Open(subFileName string) (*File, error)

Open a subfile inside an opened MPQ archive

func (*Archive) StrongSigned

func (a *Archive) StrongSigned() bool

StrongSigned checks and verifies the archive against its strong signature if present

func (*Archive) WeakSigned

func (a *Archive) WeakSigned() bool

WeakSigned checks and verifies the archive against its weak signature if present

type File

type File struct {
	// contains filtered or unexported fields
}

File stores a handle to an opened subfile in an MPQ archive

func (*File) Close

func (f *File) Close() error

Close an MPQ subfile

func (*File) Read

func (f *File) Read(b []byte) (int, error)

Read implements the io.Reader interface

func (*File) Size

func (f *File) Size() int64

Size reports the total file size in bytes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL