Documentation
¶
Overview ¶
Package archive provides functionality for reading EverQuest archive files.
Index ¶
- Constants
- Variables
- type Archive
- type BaseArchive
- func (b *BaseArchive) GetAllFiles() []File
- func (b *BaseArchive) GetFile(name string) File
- func (b *BaseArchive) GetFileByIndex(index int) File
- func (b *BaseArchive) GetFileName() string
- func (b *BaseArchive) GetFilePath() string
- func (b *BaseArchive) GetFilenameChanges() map[string]string
- func (b *BaseArchive) IsWldArchive() bool
- func (b *BaseArchive) RenameFile(originalName, newName string)
- func (b *BaseArchive) SetIsWldArchive(isWld bool)
- func (b *BaseArchive) WriteAllFiles(folder string) error
- type BaseFile
- type File
- type NullArchive
- type PfsArchive
- type PfsFile
- type T3dArchive
- type T3dFile
- type Type
Constants ¶
const ( // T3dMagicValue is the magic number for T3D archives. T3dMagicValue uint32 = 0xffff3d02 // PfsMagicValue is the magic number for PFS archives. PfsMagicValue uint32 = 0x20534650 // S3dExtension is the file extension for S3D archives. S3dExtension = ".s3d" // PfsExtension is the file extension for PFS archives. PfsExtension = ".pfs" // PakExtension is the file extension for PAK archives. PakExtension = ".pak" // T3dExtension is the file extension for T3D archives. T3dExtension = ".t3d" )
const (
// WldExtension is the file extension for WLD files.
WldExtension = ".wld"
)
Variables ¶
var ( // ErrCorruptedLength is returned when a corrupted length is detected. ErrCorruptedLength = errors.New("corrupted archive length detected") // ErrInflate is returned when decompression fails. ErrInflate = errors.New("error inflating compressed data") // ErrFileNotFound is returned when the archive file does not exist. ErrFileNotFound = errors.New("archive file does not exist") // ErrUnexpectedVersion is returned for unexpected PFS versions. ErrUnexpectedVersion = errors.New("unexpected pfs version") )
var ( // T3dMagic is the magic bytes for T3D archives. T3dMagic = []byte{0x02, 0x3D, 0xFF, 0xFF} // T3dVersion is the expected version bytes for T3D archives. T3dVersion = []byte{0x00, 0x57, 0x01, 0x00} // ErrIncorrectMagic is returned when the file magic is incorrect. ErrIncorrectMagic = errors.New("incorrect file magic") // ErrIncorrectVersion is returned when the file version is incorrect. ErrIncorrectVersion = errors.New("incorrect file version") )
var ErrNullArchive = errors.New("null archive: file does not exist or format unknown")
ErrNullArchive is returned when attempting to initialize a null archive.
var ErrUnknownArchiveType = errors.New("unknown archive type")
ErrUnknownArchiveType is returned when the archive type cannot be determined.
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive interface {
// Initialize reads and parses the archive file.
// Returns an error if initialization fails.
Initialize() error
// GetFilePath returns the full path to the archive file.
GetFilePath() string
// GetFileName returns just the filename of the archive.
GetFileName() string
// GetFile returns a file by name, or nil if not found.
GetFile(name string) File
// GetFileByIndex returns a file by index, or nil if out of range.
GetFileByIndex(index int) File
// GetAllFiles returns all files in the archive.
GetAllFiles() []File
// WriteAllFiles writes all archive files to the specified folder.
WriteAllFiles(folder string) error
// RenameFile renames a file within the archive.
RenameFile(originalName, newName string)
// IsWldArchive returns true if this archive contains WLD files.
IsWldArchive() bool
// SetIsWldArchive sets whether this archive contains WLD files.
SetIsWldArchive(isWld bool)
// GetFilenameChanges returns a map of filename changes.
GetFilenameChanges() map[string]string
}
Archive defines the interface for reading archive files.
type BaseArchive ¶
type BaseArchive struct {
FilePath string
FileName string
Files []File
FileNameRef map[string]File
Logger logger.Logger
IsWld bool
FilenameChanges map[string]string
}
BaseArchive provides common functionality for archive implementations.
func NewBaseArchive ¶
func NewBaseArchive(filePath string, log logger.Logger) *BaseArchive
NewBaseArchive creates a new BaseArchive with the given parameters.
func (*BaseArchive) GetAllFiles ¶
func (b *BaseArchive) GetAllFiles() []File
GetAllFiles returns all files in the archive.
func (*BaseArchive) GetFile ¶
func (b *BaseArchive) GetFile(name string) File
GetFile returns a file by name, or nil if not found.
func (*BaseArchive) GetFileByIndex ¶
func (b *BaseArchive) GetFileByIndex(index int) File
GetFileByIndex returns a file by index, or nil if out of range.
func (*BaseArchive) GetFileName ¶
func (b *BaseArchive) GetFileName() string
GetFileName returns just the filename of the archive.
func (*BaseArchive) GetFilePath ¶
func (b *BaseArchive) GetFilePath() string
GetFilePath returns the full path to the archive file.
func (*BaseArchive) GetFilenameChanges ¶
func (b *BaseArchive) GetFilenameChanges() map[string]string
GetFilenameChanges returns a map of filename changes.
func (*BaseArchive) IsWldArchive ¶
func (b *BaseArchive) IsWldArchive() bool
IsWldArchive returns true if this archive contains WLD files.
func (*BaseArchive) RenameFile ¶
func (b *BaseArchive) RenameFile(originalName, newName string)
RenameFile renames a file within the archive.
func (*BaseArchive) SetIsWldArchive ¶
func (b *BaseArchive) SetIsWldArchive(isWld bool)
SetIsWldArchive sets whether this archive contains WLD files.
func (*BaseArchive) WriteAllFiles ¶
func (b *BaseArchive) WriteAllFiles(folder string) error
WriteAllFiles writes all archive files to the specified folder.
type BaseFile ¶
BaseFile provides a base implementation of the File interface.
func NewBaseFile ¶
NewBaseFile creates a new BaseFile with the given parameters.
type File ¶
type File interface {
// GetName returns the name of the file.
GetName() string
// SetName sets the name of the file.
SetName(name string)
// GetSize returns the inflated size of the file in bytes.
GetSize() uint32
// GetOffset returns the positional offset of the file in the archive.
GetOffset() uint32
// GetBytes returns the inflated bytes of the file.
GetBytes() []byte
}
File represents a single file within an archive.
type NullArchive ¶
type NullArchive struct {
*BaseArchive
}
NullArchive represents an archive that could not be loaded.
func NewNullArchive ¶
func NewNullArchive(filePath string, log logger.Logger) *NullArchive
NewNullArchive creates a new NullArchive.
func (*NullArchive) Initialize ¶
func (n *NullArchive) Initialize() error
Initialize always returns an error for NullArchive.
type PfsArchive ¶
type PfsArchive struct {
*BaseArchive
}
PfsArchive represents a PFS/S3D archive.
func NewPfsArchive ¶
func NewPfsArchive(filePath string, log logger.Logger) *PfsArchive
NewPfsArchive creates a new PfsArchive.
func (*PfsArchive) Initialize ¶
func (p *PfsArchive) Initialize() error
Initialize reads and parses the PFS archive.
type PfsFile ¶
PfsFile represents a single file within a PFS archive.
func NewPfsFile ¶
NewPfsFile creates a new PfsFile with the given parameters.
type T3dArchive ¶
type T3dArchive struct {
*BaseArchive
}
T3dArchive represents a T3D archive.
func NewT3dArchive ¶
func NewT3dArchive(filePath string, log logger.Logger) *T3dArchive
NewT3dArchive creates a new T3dArchive.
func (*T3dArchive) Initialize ¶
func (t *T3dArchive) Initialize() error
Initialize reads and parses the T3D archive.
type T3dFile ¶
type T3dFile struct {
*BaseFile
}
T3dFile represents a single file within a T3D archive.
func NewT3dFile ¶
NewT3dFile creates a new T3dFile with the given parameters.