Documentation
¶
Overview ¶
Package archive provides support for reading game files from archives. It supports ZIP, 7z, and RAR formats.
Index ¶
- func DetectGameFile(arc Archive) (string, error)
- func IsArchiveExtension(ext string) bool
- func IsArchivePath(path string) bool
- func IsGameFile(filename string) bool
- type Archive
- type DiscNotSupportedError
- type FileInfo
- type FileNotFoundError
- type FormatError
- type NoGameFilesError
- type Path
- type RARArchive
- type SevenZipArchive
- type ZIPArchive
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectGameFile ¶
DetectGameFile finds the first game file in an archive. It scans the archive's file list and returns the path to the first file that has a recognized game extension.
func IsArchiveExtension ¶
IsArchiveExtension checks if an extension is a supported archive format.
func IsArchivePath ¶
IsArchivePath checks if a path references an archive. This is a quick check that doesn't verify file existence.
func IsGameFile ¶
IsGameFile checks if a filename has a recognized game file extension. This only returns true for cartridge-based game extensions.
Types ¶
type Archive ¶
type Archive interface {
// List returns all files in the archive.
List() ([]FileInfo, error)
// Open opens a file within the archive for reading.
// Returns the reader, uncompressed size, and any error.
Open(internalPath string) (io.ReadCloser, int64, error)
// OpenReaderAt opens a file and returns an io.ReaderAt interface.
// The file contents are buffered in memory to support random access.
// The returned Closer must be called to release resources.
OpenReaderAt(internalPath string) (io.ReaderAt, int64, io.Closer, error)
// Close closes the archive.
Close() error
}
Archive provides read access to files within an archive.
type DiscNotSupportedError ¶
type DiscNotSupportedError struct {
Console string
}
DiscNotSupportedError indicates disc-based games in archives are not supported.
func (DiscNotSupportedError) Error ¶
func (e DiscNotSupportedError) Error() string
type FileNotFoundError ¶
FileNotFoundError indicates a file was not found in the archive.
func (FileNotFoundError) Error ¶
func (e FileNotFoundError) Error() string
type FormatError ¶
FormatError indicates an unsupported or invalid archive format.
func (FormatError) Error ¶
func (e FormatError) Error() string
type NoGameFilesError ¶
type NoGameFilesError struct {
Archive string
}
NoGameFilesError indicates no game files were found in the archive.
func (NoGameFilesError) Error ¶
func (e NoGameFilesError) Error() string
type Path ¶
type Path struct {
ArchivePath string // Path to the archive file
InternalPath string // Path inside the archive (empty means auto-detect)
}
Path represents a parsed archive path with optional internal path.
func ParsePath ¶
ParsePath parses a path that may reference a file inside an archive. It supports MiSTer-style paths like "/path/to/archive.zip/folder/game.gba".
Returns:
- (*Path, nil) if the path contains an archive reference
- (nil, nil) if the path is not an archive reference
- (nil, error) if there was an error checking the path
type RARArchive ¶
type RARArchive struct {
// contains filtered or unexported fields
}
RARArchive provides access to files in a RAR archive.
func OpenRAR ¶
func OpenRAR(path string) (*RARArchive, error)
OpenRAR opens a RAR archive for reading.
func (*RARArchive) List ¶
func (ra *RARArchive) List() ([]FileInfo, error)
List returns all files in the RAR archive.
func (*RARArchive) Open ¶
func (ra *RARArchive) Open(internalPath string) (io.ReadCloser, int64, error)
Open opens a file within the RAR archive. Note: RAR archives require sequential reading, so this seeks through the archive.
func (*RARArchive) OpenReaderAt ¶
OpenReaderAt opens a file and returns an io.ReaderAt interface. The file contents are buffered in memory.
type SevenZipArchive ¶
type SevenZipArchive struct {
// contains filtered or unexported fields
}
SevenZipArchive provides access to files in a 7z archive.
func OpenSevenZip ¶
func OpenSevenZip(path string) (*SevenZipArchive, error)
OpenSevenZip opens a 7z archive for reading.
func (*SevenZipArchive) Close ¶
func (sza *SevenZipArchive) Close() error
Close closes the 7z archive.
func (*SevenZipArchive) List ¶
func (sza *SevenZipArchive) List() ([]FileInfo, error)
List returns all files in the 7z archive.
func (*SevenZipArchive) Open ¶
func (sza *SevenZipArchive) Open(internalPath string) (io.ReadCloser, int64, error)
Open opens a file within the 7z archive.
func (*SevenZipArchive) OpenReaderAt ¶
func (sza *SevenZipArchive) OpenReaderAt(internalPath string) (io.ReaderAt, int64, io.Closer, error)
OpenReaderAt opens a file and returns an io.ReaderAt interface. The file contents are buffered in memory.
type ZIPArchive ¶
type ZIPArchive struct {
// contains filtered or unexported fields
}
ZIPArchive provides access to files in a ZIP archive.
func OpenZIP ¶
func OpenZIP(path string) (*ZIPArchive, error)
OpenZIP opens a ZIP archive for reading.
func (*ZIPArchive) List ¶
func (za *ZIPArchive) List() ([]FileInfo, error)
List returns all files in the ZIP archive.
func (*ZIPArchive) Open ¶
func (za *ZIPArchive) Open(internalPath string) (io.ReadCloser, int64, error)
Open opens a file within the ZIP archive.
func (*ZIPArchive) OpenReaderAt ¶
OpenReaderAt opens a file and returns an io.ReaderAt interface. The file contents are buffered in memory.