Documentation
¶
Index ¶
- func DeleteFileByPath(parent *Dir, path string) bool
- func NameHashUTF16(name string) uint64
- func NameHashUTF8(name string) uint64
- func Pack(dirPath string, arcPath string) error
- func UniqueIDHash(fullName string) uint64
- type Arc
- func (arc *Arc) CopyFile(srcPath string, dstPath string) error
- func (arc *Arc) CreateFile(path string, data []byte) *File
- func (arc *Arc) DeleteFile(path string) bool
- func (arc *Arc) Dump(path string) error
- func (arc *Arc) GetFile(path string) *File
- func (arc *Arc) GetFileList() []string
- func (arc *Arc) MergeFrom(src *Arc, keepDupes bool)
- func (arc *Arc) Unpack(outDir string) error
- type ArcPointer
- type Dir
- type File
- type FilePointer
- type MemoryPointer
- type MemoryPointerCompressed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteFileByPath ¶
DeleteFileByPath removes a file identified by its relative path from the specified parent directory and returns success status.
func NameHashUTF16 ¶
NameHashUTF16 computes name hash (lowercased input) as UTF-16LE
func NameHashUTF8 ¶
NameHashUTF8 computes name hash (lowercased input) as UTF-8
func UniqueIDHash ¶
UniqueIDHash computes the unique id hash of a full name encoded as UTF-16LE without lowercasing
Types ¶
type Arc ¶
type Arc struct {
Name string // Name represents the name of the ARC file system or directory node.
Root *Dir // Root represents the root directory of the ARC file system.
KeepDupes bool // KeepDupes determines whether duplicate files are allowed based on their full path rather than just the name.
CompressGlobs []string // CompressGlobs specifies glob patterns for file compression within the ARC file system.
}
Arc represents an ARC file system in memory
func ReadArc ¶
func ReadArc(rs io.ReadSeeker) (*Arc, error)
ReadArc parses an ARC file and returns an in-memory Arc representation
func (*Arc) CopyFile ¶
CopyFile copies a file from the specified source path to the destination path within the Arc file system.
func (*Arc) CreateFile ¶
CreateFile creates a new file at the specified path within the Arc file system and sets its data. creates a file node in the directory tree at the specified path relative to the given parent directory.
func (*Arc) DeleteFile ¶
DeleteFile removes a file identified by its relative path within the Arc file system. Returns true if the file was deleted.
func (*Arc) GetFile ¶
GetFile retrieves a file within the Arc file system by its relative path or returns nil if the file is not found.
func (*Arc) GetFileList ¶
GetFileList retrieves a list of all files in the Arc file system with their relative paths.
type ArcPointer ¶
type ArcPointer struct {
// contains filtered or unexported fields
}
ArcPointer lazily reads from an .arc file at a given offset The offset points to the start of the 16-byte per-file header [u32 compressed][u32 padding][u32 rawSize][u32 size] followed by data
func NewArcPointer ¶
func NewArcPointer(reader *stream.BinaryReader, 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 {
Arc *Arc // Arc represents a pointer to the Arc file system associated with this directory node.
Name string // Name represents the name of the directory.
Parent *Dir // Parent represents the parent directory of the current directory node in the filesystem hierarchy.
Dirs map[string]*Dir // Dirs maps directory names to their corresponding directory nodes within the current directory.
Files map[string]*File // Files maps file names to their corresponding file nodes within the current directory.
}
Dir represents a directory node
func AllDirs ¶
AllDirs returns a list of all directories in the given Arc file system in depth-first order, excluding duplicates.
func GetOrCreateDirByPath ¶
GetOrCreateDirByPath navigates through or creates directories along the specified path starting from the given parent directory.
func (*Dir) GetOrCreateDir ¶
GetOrCreateDir finds or creates a directory by name under this dir
func (*Dir) UTF16Hash ¶
UTF16Hash computes a hash for the directory name using UTF-16LE encoding and case-insensitive comparison.
type File ¶
type File struct {
Arc *Arc // Arc points to the ARC file system that this file belongs to.
Name string // Name represents the name of the file or directory node.
Parent *Dir // Parent represents the parent directory of the current file node in the filesystem hierarchy.
Ptr FilePointer // Ptr represents a memory or compressed pointer to the file data.
}
File represents a file node with a data pointer
func AddFileByPath ¶
AddFileByPath creates a file node in the directory tree at the specified path relative to the given parent directory.
func AllFiles ¶
AllFiles returns a slice of all files in the provided Arc file system in a recursive traversal from the root directory.
func FindFileByPath ¶
FindFileByPath retrieves a file by its path relative to the given parent directory or returns nil if not found.
func (*File) RelativePath ¶
RelativePath returns the path of the file relative to the Arc root.
func (*File) UTF16Hash ¶
UTF16Hash computes and returns a hash value for the file name using UTF-16 encoding and case-insensitive comparison.
type FilePointer ¶
type FilePointer interface {
Compressed() bool // Compressed indicates if the file data is compressed.
Data() ([]byte, error) // Data retrieves the file data as a byte slice.
RawSize() uint32 // RawSize returns the uncompressed file size in bytes.
Size() uint32 // Size returns the file size in bytes, respecting compression if applied.
}
FilePointer represents an interface for managing file data within an ARC file system.
type MemoryPointer ¶
type MemoryPointer struct {
// contains filtered or unexported fields
}
MemoryPointer represents a structure that encapsulates a memory buffer as a slice of bytes.
func NewMemoryPointer ¶
func NewMemoryPointer(data []byte) *MemoryPointer
NewMemoryPointer creates a new MemoryPointer instance with a copy of the provided byte slice.
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
}
MemoryPointerCompressed represents a data structure for managing compressed data and its raw size.
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