arc

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFileByPath

func DeleteFileByPath(parent *Dir, path string) bool

func Detect

func Detect(path string) (bool, error)

Detect checks if a file seems to be an ARC by verifying magic header

func NameHashUTF16

func NameHashUTF16(name string) uint64

NameHashUTF16 computes name hash (lowercased input) as UTF-16LE

func NameHashUTF8

func NameHashUTF8(name string) uint64

NameHashUTF8 computes name hash (lowercased input) as UTF-8

func Pack

func Pack(dirPath string, arcPath string) error

Pack loads all files from dirPath into an Arc structure and dumps it to arcPath

func UniqueIDHash

func UniqueIDHash(fullName string) uint64

UniqueIDHash computes the unique id hash of a full name encoded as UTF-16LE without lowercasing

func UnpackArc

func UnpackArc(arcPath, outDir string) error

UnpackArc is a helper to read an ARC file and unpack it to a directory.

Types

type Arc

type Arc struct {
	Name          string
	Root          *Dir
	KeepDupes     bool
	CompressGlobs []string
}

Arc represents an ARC file system in memory It mirrors the structure used by the original C# ArcFileSystem.

func New

func New(name string) *Arc

New creates a new empty ARC file system

func ReadArc

func ReadArc(path string) (*Arc, error)

ReadArc parses an ARC file and returns an in-memory Arc representation

func (*Arc) CopyFile

func (fs *Arc) CopyFile(srcPath, dstPath string) error

func (*Arc) CreateFile

func (fs *Arc) CreateFile(path string, data []byte) *File

func (*Arc) DeleteFile

func (fs *Arc) DeleteFile(path string) bool

func (*Arc) Dump

func (fs *Arc) Dump(path string) error

Dump writes the Arc to an ARC file on disk

func (*Arc) GetFile

func (fs *Arc) GetFile(path string) *File

func (*Arc) GetFileList

func (fs *Arc) GetFileList() []string

func (*Arc) MergeFrom

func (fs *Arc) MergeFrom(src *Arc, keepDupes bool)

MergeFrom merges src into this Arc. If keepDupes is true, use full path as key for files; otherwise last segment.

func (*Arc) Unpack

func (fs *Arc) Unpack(outDir string) error

Unpack extracts the entire Arc file system to the specified directory.

type ArcPointer

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

func NewArcPointer

func NewArcPointer(path string, offset int64) *ArcPointer

func (*ArcPointer) Compressed

func (a *ArcPointer) Compressed() bool

func (*ArcPointer) Data

func (a *ArcPointer) Data() ([]byte, error)

func (*ArcPointer) RawSize

func (a *ArcPointer) RawSize() uint32

func (*ArcPointer) Size

func (a *ArcPointer) Size() uint32

type Dir

type Dir struct {
	Name   string
	Parent *Dir
	Dirs   map[string]*Dir
	Files  map[string]*File
	// contains filtered or unexported fields
}

Dir represents a directory node

func AllDirs

func AllDirs(fs *Arc) []*Dir

func GetOrCreateDirByPath

func GetOrCreateDirByPath(parent *Dir, path string) *Dir

func (*Dir) AddFile

func (d *Dir) AddFile(f *File)

AddFile adds or replaces a file entry under this dir

func (*Dir) Depth

func (d *Dir) Depth() int

Depth returns the depth in the tree

func (*Dir) FullName

func (d *Dir) FullName() string

FullName returns full path with OS separator

func (*Dir) GetOrCreateDir

func (d *Dir) GetOrCreateDir(name string) *Dir

GetOrCreateDir finds or creates a directory by name under this dir

func (*Dir) UTF16Hash

func (d *Dir) UTF16Hash() uint64

func (*Dir) UTF8Hash

func (d *Dir) UTF8Hash() uint64

func (*Dir) UniqueID

func (d *Dir) UniqueID() uint64

type File

type File struct {
	Name   string
	Parent *Dir
	Ptr    FilePointer
	// contains filtered or unexported fields
}

File represents a file node with data pointer

func AddFileByPath

func AddFileByPath(parent *Dir, path string) *File

func AllFiles

func AllFiles(fs *Arc) []*File

func FindFileByPath

func FindFileByPath(parent *Dir, path string) *File

func (*File) Extract

func (f *File) Extract(outPath string) error

Extract saves the file to the specified path.

func (*File) FullName

func (f *File) FullName() string

FullName returns full path including parent dirs

func (*File) RelativePath

func (f *File) RelativePath() string

RelativePath returns the path of the file relative to the Arc root.

func (*File) SetData

func (f *File) SetData(b []byte, compressed bool)

SetData sets file data using a memory pointer

func (*File) UTF16Hash

func (f *File) UTF16Hash() uint64

func (*File) UTF8Hash

func (f *File) UTF8Hash() uint64

func (*File) UniqueID

func (f *File) UniqueID() uint64

type FilePointer

type FilePointer interface {
	Compressed() bool
	Data() ([]byte, error)
	RawSize() uint32
	Size() uint32
}

type MemoryPointer

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

func NewMemoryPointer

func NewMemoryPointer(data []byte) *MemoryPointer

func (*MemoryPointer) Compressed

func (m *MemoryPointer) Compressed() bool

func (*MemoryPointer) Data

func (m *MemoryPointer) Data() ([]byte, error)

func (*MemoryPointer) RawSize

func (m *MemoryPointer) RawSize() uint32

func (*MemoryPointer) Size

func (m *MemoryPointer) Size() uint32

type MemoryPointerCompressed

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

func NewMemoryPointerCompressed

func NewMemoryPointerCompressed(compressed []byte, rawSize uint32) *MemoryPointerCompressed

func NewMemoryPointerCompressedAuto

func NewMemoryPointerCompressedAuto(compressed []byte) *MemoryPointerCompressed

NewMemoryPointerCompressedAuto tries to determine raw size by decompressing

func (*MemoryPointerCompressed) Compressed

func (m *MemoryPointerCompressed) Compressed() bool

func (*MemoryPointerCompressed) Data

func (m *MemoryPointerCompressed) Data() ([]byte, error)

func (*MemoryPointerCompressed) RawSize

func (m *MemoryPointerCompressed) RawSize() uint32

func (*MemoryPointerCompressed) Size

func (m *MemoryPointerCompressed) Size() uint32

Jump to

Keyboard shortcuts

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