Documentation
¶
Index ¶
- func DeleteFileByPath(parent *Dir, path string) bool
- func NameHashUTF8(name string) uint64
- func NameHashUTF16(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 从给定父目录删除相对路径所标识的文件并返回成功状态 DeleteFileByPath removes a file identified by its relative path from the specified parent directory and returns success status
func NameHashUTF8 ¶
NameHashUTF8 将输入转换为小写并按 UTF-8 计算名称哈希 NameHashUTF8 computes name hash (lowercased input) as UTF-8
func NameHashUTF16 ¶
NameHashUTF16 将输入转换为小写并按 UTF-16LE 计算名称哈希 NameHashUTF16 computes name hash (lowercased input) as UTF-16LE
func Pack ¶
Pack 将 dirPath 中的全部文件载入 Arc 结构并写到 arcPath Pack loads all files from dirPath into an Arc structure and dumps it to arcPath
func UniqueIDHash ¶
UniqueIDHash 对不转换小写的完整名称按 UTF-16LE 计算唯一 ID 哈希 UniqueIDHash computes the unique id hash of a full name encoded as UTF-16LE without lowercasing
Types ¶
type Arc ¶
type Arc struct {
Name string // ARC 文件系统或目录节点的名称 / Name represents the name of the ARC file system or directory node
Root *Dir // ARC 文件系统的根目录 / 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 // ARC 文件系统内用于压缩文件的通配模式 / CompressGlobs specifies glob patterns for file compression within the ARC file system
}
Arc 表示内存中的 ARC 文件系统 Arc represents an ARC file system in memory
func ReadArc ¶
func ReadArc(rs io.ReadSeeker) (*Arc, error)
ReadArc 从 rs 解析 ARC 元数据 文件载荷仍由 rs 延迟支持,因此后续 Data 或 Extract 调用时调用方必须保持 rs 可读,需要脱离源流时使用 ReadArcFile 或 ReadArcBytes ReadArc parses ARC metadata from rs File payloads remain lazily backed by rs, so callers must keep rs readable for later Data or Extract calls Use ReadArcFile or ReadArcBytes when a detached Arc is required
func ReadArcBytes ¶
ReadArcBytes 从内存中解析 ARC 载荷 返回的 Arc 延迟读取内存缓冲区,不依赖打开的文件句柄 ReadArcBytes parses an ARC payload from memory The returned Arc lazily reads from the in-memory buffer and does not depend on an open file handle
func ReadArcFile ¶
ReadArcFile 将 ARC 文件读入内存后解析 当源文件关闭后仍需使用返回的 Arc 时使用此函数 ReadArcFile loads an ARC file into memory before parsing it Use this when the returned Arc must remain usable after the source file is closed
func (*Arc) CopyFile ¶
CopyFile 在 ARC 文件系统中将文件从指定源路径复制到目标路径 CopyFile copies a file from the specified source path to the destination path within the Arc file system
func (*Arc) CreateFile ¶
CreateFile 在 ARC 文件系统中的指定路径创建新文件并设置其数据 此函数在目录树中按相对于给定父目录的指定路径创建文件节点 CreateFile creates a new file at the specified path within the Arc file system and sets its data This creates a file node in the directory tree at the specified path relative to the given parent directory
func (*Arc) DeleteFile ¶
DeleteFile 删除 ARC 文件系统中相对路径所标识的文件,成功删除时返回 true DeleteFile removes a file identified by its relative path within the Arc file system and returns true if the file was deleted
func (*Arc) GetFile ¶
GetFile 按相对路径获取 ARC 文件系统中的文件,未找到时返回 nil 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 获取 ARC 文件系统中所有文件及其相对路径的列表 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 从 ARC 文件中的给定偏移延迟读取数据 此偏移指向每个文件所用的 16 字节头部起始位置 头部依次为压缩标志、保留值、原始大小和存储大小,随后是文件数据 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
NewArcPointer 创建一个从给定文件头偏移读取数据的延迟指针 NewArcPointer creates a lazy pointer that reads data from the given file-header offset
func (*ArcPointer) Compressed ¶
func (a *ArcPointer) Compressed() bool
Compressed 返回文件头中的压缩标志,读取错误时返回当前缓存值 Compressed returns the header compression flag and returns the cached value on read failure
func (*ArcPointer) Data ¶
func (a *ArcPointer) Data() ([]byte, error)
Data 根据已缓存的偏移和大小读取 ARC 中的数据字节 Data reads the ARC data bytes using the cached offset and size
func (*ArcPointer) RawSize ¶
func (a *ArcPointer) RawSize() uint32
RawSize 返回文件头记录的解压后大小 RawSize returns the uncompressed size recorded in the file header
func (*ArcPointer) Size ¶
func (a *ArcPointer) Size() uint32
Size 返回文件头记录的 ARC 存储大小 Size returns the ARC storage size recorded in the file header
type Dir ¶
type Dir struct {
Arc *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 表示目录节点 Dir represents a directory node
func AllDirs ¶
AllDirs 返回给定 ARC 文件系统中按深度优先顺序排列且不重复的所有目录 AllDirs returns a list of all directories in the given Arc file system in depth-first order, excluding duplicates
func GetOrCreateDirByPath ¶
GetOrCreateDirByPath 从给定父目录开始沿指定路径查找或创建目录 GetOrCreateDirByPath navigates through or creates directories along the specified path starting from the given parent directory
func (*Dir) GetOrCreateDir ¶
GetOrCreateDir 在当前目录下查找或创建指定名称的目录 GetOrCreateDir finds or creates a directory by name under this dir
func (*Dir) UTF8Hash ¶
UTF8Hash 使用 UTF-8 编码和不区分大小写的比较方式计算目录名哈希 UTF8Hash computes a hash for the directory name using UTF-8 encoding and case-insensitive comparison
type File ¶
type File struct {
Arc *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 表示带有数据指针的文件节点 File represents a file node with a data pointer
func AddFileByPath ¶
AddFileByPath 在给定父目录的指定相对路径中创建文件节点 AddFileByPath creates a file node in the directory tree at the specified path relative to the given parent directory
func AllFiles ¶
AllFiles 返回从根目录递归遍历给定 ARC 文件系统得到的所有文件 AllFiles returns a slice of all files in the provided Arc file system in a recursive traversal from the root directory
func FindFileByPath ¶
FindFileByPath 按相对于给定父目录的路径获取文件,未找到时返回 nil FindFileByPath retrieves a file by its path relative to the given parent directory or returns nil if not found
func (*File) RelativePath ¶
RelativePath 返回文件相对于 ARC 根目录的路径 RelativePath returns the path of the file relative to the Arc root
func (*File) UTF8Hash ¶
UTF8Hash 使用 UTF-8 编码和不区分大小写的比较方式计算并返回文件名哈希 UTF8Hash computes and returns a hash value for the file name using UTF-8 encoding and case-insensitive comparison
type FilePointer ¶
type FilePointer interface {
Compressed() bool // Compressed 表示文件数据是否已压缩 / Compressed indicates if the file data is compressed
Data() ([]byte, error) // Data 以字节切片形式获取文件数据 / Data retrieves the file data as a byte slice
RawSize() uint32 // RawSize 返回未压缩文件的字节大小 / RawSize returns the uncompressed file size in bytes
Size() uint32 // Size 返回文件的存储字节大小,并反映是否应用压缩 / Size returns the file size in bytes, respecting compression if applied
}
FilePointer 表示用于管理 ARC 文件系统内文件数据的接口 FilePointer represents an interface for managing file data within an ARC file system
type MemoryPointer ¶
type MemoryPointer struct {
// contains filtered or unexported fields
}
MemoryPointer 表示将内存缓冲区封装为字节切片的结构 MemoryPointer represents a structure that encapsulates a memory buffer as a slice of bytes
func NewMemoryPointer ¶
func NewMemoryPointer(data []byte) *MemoryPointer
NewMemoryPointer 创建一个复制所提供字节切片的新 MemoryPointer 实例 NewMemoryPointer creates a new MemoryPointer instance with a copy of the provided byte slice
func (*MemoryPointer) Compressed ¶
func (m *MemoryPointer) Compressed() bool
Compressed 始终返回 false,因为该指针保存未压缩数据 Compressed always returns false because this pointer stores uncompressed data
func (*MemoryPointer) Data ¶
func (m *MemoryPointer) Data() ([]byte, error)
Data 返回未压缩数据的副本 Data returns a copy of the uncompressed data
func (*MemoryPointer) RawSize ¶
func (m *MemoryPointer) RawSize() uint32
RawSize 返回未压缩数据的字节数 RawSize returns the number of bytes in the uncompressed data
func (*MemoryPointer) Size ¶
func (m *MemoryPointer) Size() uint32
Size 返回未压缩数据在 ARC 中的存储字节数 Size returns the number of bytes used to store the uncompressed data in the ARC
type MemoryPointerCompressed ¶
type MemoryPointerCompressed struct {
// contains filtered or unexported fields
}
MemoryPointerCompressed 表示用于管理压缩数据及其原始大小的结构 MemoryPointerCompressed represents a data structure for managing compressed data and its raw size
func NewMemoryPointerCompressed ¶
func NewMemoryPointerCompressed(compressed []byte, rawSize uint32) *MemoryPointerCompressed
NewMemoryPointerCompressed 创建一个保存压缩数据的内存指针 NewMemoryPointerCompressed creates a memory pointer for already compressed data
func NewMemoryPointerCompressedAuto ¶
func NewMemoryPointerCompressedAuto(compressed []byte) *MemoryPointerCompressed
NewMemoryPointerCompressedAuto 尝试通过解压数据确定原始大小,解压失败时将原始大小保留为零 NewMemoryPointerCompressedAuto tries to determine raw size by decompressing and leaves it at zero when decompression fails
func (*MemoryPointerCompressed) Compressed ¶
func (m *MemoryPointerCompressed) Compressed() bool
Compressed 始终返回 true,因为该指针保存压缩数据 Compressed always returns true because this pointer stores compressed data
func (*MemoryPointerCompressed) Data ¶
func (m *MemoryPointerCompressed) Data() ([]byte, error)
Data 返回压缩数据的副本 Data returns a copy of the compressed data
func (*MemoryPointerCompressed) RawSize ¶
func (m *MemoryPointerCompressed) RawSize() uint32
RawSize 返回压缩数据解压后的大小 RawSize returns the size of the compressed data after decompression
func (*MemoryPointerCompressed) Size ¶
func (m *MemoryPointerCompressed) Size() uint32
Size 返回压缩数据在 ARC 中的存储字节数 Size returns the number of bytes used to store the compressed data in the ARC