Documentation
¶
Overview ¶
Package identifier provides console-specific game identification logic.
Index ¶
- Variables
- func ValidateGB(header []byte) bool
- func ValidateGBA(header []byte) bool
- func ValidateGC(header []byte) bool
- func ValidateGenesis(data []byte) bool
- func ValidateN64(header []byte) bool
- func ValidateSNES(data []byte) bool
- func ValidateSaturn(header []byte) bool
- func ValidateSegaCD(header []byte) bool
- type Console
- type Database
- type DiscIdentifier
- type ErrInvalidFormat
- type ErrNotSupported
- type FileInfo
- type GBAIdentifier
- type GBIdentifier
- type GCIdentifier
- type GenesisIdentifier
- type ISOReader
- type Identifier
- type InvalidFormatError
- type N64Identifier
- type NESIdentifier
- type NeoGeoCDIdentifier
- type NotSupportedError
- type PS2Identifier
- type PSPIdentifier
- type PSXIdentifier
- type Result
- type SNESIdentifier
- type SaturnIdentifier
- type SegaCDIdentifier
Constants ¶
This section is empty.
Variables ¶
var AllConsoles = []Console{ ConsoleGB, ConsoleGBC, ConsoleGBA, ConsoleGC, ConsoleGenesis, ConsoleN64, ConsoleNeoGeoCD, ConsoleNES, ConsolePSP, ConsolePSX, ConsolePS2, ConsoleSaturn, ConsoleSegaCD, ConsoleSNES, }
AllConsoles is a list of all supported consoles.
Functions ¶
func ValidateGB ¶
ValidateGB checks if the given data looks like a valid GB/GBC ROM.
func ValidateGBA ¶
ValidateGBA checks if the given data looks like a valid GBA ROM.
func ValidateGC ¶
ValidateGC checks if the given data looks like a valid GameCube disc.
func ValidateGenesis ¶
ValidateGenesis checks if the given data looks like a valid Genesis ROM.
func ValidateN64 ¶
ValidateN64 checks if the given data looks like a valid N64 ROM.
func ValidateSNES ¶
ValidateSNES checks if the given data looks like a valid SNES ROM.
func ValidateSaturn ¶
ValidateSaturn checks if the given data looks like a valid Saturn disc.
func ValidateSegaCD ¶
ValidateSegaCD checks if the given data looks like a valid Sega CD disc.
Types ¶
type Console ¶
type Console string
Console represents a gaming console/platform.
const ( ConsoleGB Console = "GB" ConsoleGBC Console = "GBC" ConsoleGBA Console = "GBA" ConsoleGC Console = "GC" ConsoleGenesis Console = "Genesis" ConsoleN64 Console = "N64" ConsoleNeoGeoCD Console = "NeoGeoCD" ConsoleNES Console = "NES" ConsolePSP Console = "PSP" ConsolePSX Console = "PSX" ConsolePS2 Console = "PS2" ConsoleSaturn Console = "Saturn" ConsoleSegaCD Console = "SegaCD" ConsoleSNES Console = "SNES" )
Supported console types.
type Database ¶
type Database interface {
// Lookup retrieves metadata for a game by console and key.
// The key format varies by console (see plan for details).
Lookup(console Console, key any) (map[string]string, bool)
// LookupByString retrieves metadata using a string key.
LookupByString(console Console, key string) (map[string]string, bool)
// GetIDPrefixes returns the ID prefixes for disc-based consoles (PSX, PS2).
GetIDPrefixes(console Console) []string
}
Database provides lookup capabilities for game metadata.
type DiscIdentifier ¶
type DiscIdentifier interface {
Identifier
// IdentifyFromISO identifies a game from a parsed ISO filesystem.
// This is used when the ISO has already been parsed.
IdentifyFromISO(iso ISOReader, db Database) (*Result, error)
}
DiscIdentifier is an extended interface for disc-based games.
type ErrInvalidFormat ¶
type ErrInvalidFormat = InvalidFormatError
ErrInvalidFormat is deprecated; use InvalidFormatError instead.
type ErrNotSupported ¶
type ErrNotSupported = NotSupportedError
ErrNotSupported is deprecated; use NotSupportedError instead.
type GBAIdentifier ¶
type GBAIdentifier struct{}
GBAIdentifier identifies Game Boy Advance games.
func NewGBAIdentifier ¶
func NewGBAIdentifier() *GBAIdentifier
NewGBAIdentifier creates a new GBA identifier.
func (*GBAIdentifier) Console ¶
func (*GBAIdentifier) Console() Console
Console returns the console type.
type GBIdentifier ¶
type GBIdentifier struct {
// ForceGBC forces identification as GBC even when the ROM supports both
ForceGBC bool
}
GBIdentifier identifies Game Boy and Game Boy Color games.
func NewGBIdentifier ¶
func NewGBIdentifier() *GBIdentifier
NewGBIdentifier creates a new GB/GBC identifier.
func (*GBIdentifier) Console ¶
func (*GBIdentifier) Console() Console
Console returns the console type.
type GCIdentifier ¶
type GCIdentifier struct{}
GCIdentifier identifies GameCube games.
func NewGCIdentifier ¶
func NewGCIdentifier() *GCIdentifier
NewGCIdentifier creates a new GameCube identifier.
func (*GCIdentifier) Console ¶
func (*GCIdentifier) Console() Console
Console returns the console type.
func (*GCIdentifier) IdentifyFromPath ¶
func (g *GCIdentifier) IdentifyFromPath(path string, db Database) (*Result, error)
IdentifyFromPath handles path-based identification for GameCube discs. This is needed for CHD files which require special handling.
type GenesisIdentifier ¶
type GenesisIdentifier struct{}
GenesisIdentifier identifies Sega Genesis / Mega Drive games.
func NewGenesisIdentifier ¶
func NewGenesisIdentifier() *GenesisIdentifier
NewGenesisIdentifier creates a new Genesis identifier.
func (*GenesisIdentifier) Console ¶
func (*GenesisIdentifier) Console() Console
Console returns the console type.
type ISOReader ¶
type ISOReader interface {
// GetSystemID returns the system identifier from the PVD.
GetSystemID() string
// GetVolumeID returns the volume identifier from the PVD.
GetVolumeID() string
// GetPublisherID returns the publisher identifier from the PVD.
GetPublisherID() string
// GetDataPreparerID returns the data preparer identifier from the PVD.
GetDataPreparerID() string
// GetUUID returns a unique identifier derived from disc metadata.
GetUUID() string
// IterFiles returns a list of files in the filesystem.
// If onlyRootDir is true, only files in the root directory are returned.
IterFiles(onlyRootDir bool) ([]FileInfo, error)
// ReadFile reads the contents of a file.
ReadFile(path string) ([]byte, error)
// FileExists checks if a file exists at the given path.
FileExists(path string) bool
}
ISOReader provides read access to an ISO9660 filesystem.
type Identifier ¶
type Identifier interface {
// Identify extracts game information from the given reader.
// The reader should be positioned at the start of the file.
// size is the total file size.
// db can be nil if no database lookup is needed.
Identify(r io.ReaderAt, size int64, db Database) (*Result, error)
// Console returns the console type this identifier handles.
Console() Console
}
Identifier is the interface for console-specific identification.
type InvalidFormatError ¶
InvalidFormatError is returned when a file doesn't match the expected format.
func (InvalidFormatError) Error ¶
func (e InvalidFormatError) Error() string
type N64Identifier ¶
type N64Identifier struct{}
N64Identifier identifies Nintendo 64 games.
func NewN64Identifier ¶
func NewN64Identifier() *N64Identifier
NewN64Identifier creates a new N64 identifier.
func (*N64Identifier) Console ¶
func (*N64Identifier) Console() Console
Console returns the console type.
type NESIdentifier ¶
type NESIdentifier struct{}
NESIdentifier identifies Nintendo Entertainment System games. NES identification relies on CRC32 checksum of the entire file.
func NewNESIdentifier ¶
func NewNESIdentifier() *NESIdentifier
NewNESIdentifier creates a new NES identifier.
func (*NESIdentifier) Console ¶
func (*NESIdentifier) Console() Console
Console returns the console type.
type NeoGeoCDIdentifier ¶
type NeoGeoCDIdentifier struct{}
NeoGeoCDIdentifier identifies Neo Geo CD games.
func NewNeoGeoCDIdentifier ¶
func NewNeoGeoCDIdentifier() *NeoGeoCDIdentifier
NewNeoGeoCDIdentifier creates a new Neo Geo CD identifier.
func (*NeoGeoCDIdentifier) Console ¶
func (*NeoGeoCDIdentifier) Console() Console
Console returns the console type.
func (*NeoGeoCDIdentifier) Identify ¶
Identify extracts Neo Geo CD game information from the given reader. For disc-based games, use IdentifyFromPath instead.
func (*NeoGeoCDIdentifier) IdentifyFromPath ¶
func (n *NeoGeoCDIdentifier) IdentifyFromPath(path string, database Database) (*Result, error)
IdentifyFromPath identifies a Neo Geo CD game from a file path.
type NotSupportedError ¶
type NotSupportedError struct {
Format string
}
NotSupportedError is returned when a file format is not supported.
func (NotSupportedError) Error ¶
func (e NotSupportedError) Error() string
type PS2Identifier ¶
type PS2Identifier struct{}
PS2Identifier identifies PlayStation 2 games.
func NewPS2Identifier ¶
func NewPS2Identifier() *PS2Identifier
NewPS2Identifier creates a new PS2 identifier.
func (*PS2Identifier) Console ¶
func (*PS2Identifier) Console() Console
Console returns the console type.
func (*PS2Identifier) Identify ¶
Identify extracts PS2 game information from the given reader. For disc-based games, use IdentifyFromPath instead.
func (*PS2Identifier) IdentifyFromPath ¶
func (*PS2Identifier) IdentifyFromPath(path string, database Database) (*Result, error)
IdentifyFromPath identifies a PS2 game from a file path.
type PSPIdentifier ¶
type PSPIdentifier struct{}
PSPIdentifier identifies PlayStation Portable games.
func NewPSPIdentifier ¶
func NewPSPIdentifier() *PSPIdentifier
NewPSPIdentifier creates a new PSP identifier.
func (*PSPIdentifier) Console ¶
func (*PSPIdentifier) Console() Console
Console returns the console type.
func (*PSPIdentifier) Identify ¶
Identify extracts PSP game information from the given reader. For disc-based games, use IdentifyFromPath instead.
func (*PSPIdentifier) IdentifyFromPath ¶
func (*PSPIdentifier) IdentifyFromPath(path string, database Database) (*Result, error)
IdentifyFromPath identifies a PSP game from a file path.
type PSXIdentifier ¶
type PSXIdentifier struct{}
PSXIdentifier identifies PlayStation games.
func NewPSXIdentifier ¶
func NewPSXIdentifier() *PSXIdentifier
NewPSXIdentifier creates a new PSX identifier.
func (*PSXIdentifier) Console ¶
func (*PSXIdentifier) Console() Console
Console returns the console type.
func (*PSXIdentifier) Identify ¶
Identify extracts PSX game information from the given reader. For disc-based games, use IdentifyFromPath instead.
func (*PSXIdentifier) IdentifyFromPath ¶
func (*PSXIdentifier) IdentifyFromPath(path string, database Database) (*Result, error)
IdentifyFromPath identifies a PSX game from a file path.
type Result ¶
type Result struct {
Metadata map[string]string
ID string
Title string
Console Console
InternalTitle string
Region string
}
Result contains the identification results for a game.
func (*Result) MergeMetadata ¶
MergeMetadata merges database metadata into the result. Database values only fill in missing fields.
func (*Result) MergeMetadataPreferDB ¶
MergeMetadataPreferDB merges database metadata into the result. Database values overwrite extracted values.
func (*Result) SetMetadata ¶
SetMetadata sets a metadata value, also updating the Result fields if applicable.
type SNESIdentifier ¶
type SNESIdentifier struct{}
SNESIdentifier identifies Super Nintendo games.
func NewSNESIdentifier ¶
func NewSNESIdentifier() *SNESIdentifier
NewSNESIdentifier creates a new SNES identifier.
func (*SNESIdentifier) Console ¶
func (*SNESIdentifier) Console() Console
Console returns the console type.
type SaturnIdentifier ¶
type SaturnIdentifier struct{}
SaturnIdentifier identifies Sega Saturn games.
func NewSaturnIdentifier ¶
func NewSaturnIdentifier() *SaturnIdentifier
NewSaturnIdentifier creates a new Saturn identifier.
func (*SaturnIdentifier) Console ¶
func (*SaturnIdentifier) Console() Console
Console returns the console type.
func (*SaturnIdentifier) Identify ¶
Identify extracts Saturn game information from the given reader.
func (*SaturnIdentifier) IdentifyFromPath ¶
func (s *SaturnIdentifier) IdentifyFromPath(path string, database Database) (*Result, error)
IdentifyFromPath identifies a Saturn game from a file path.
type SegaCDIdentifier ¶
type SegaCDIdentifier struct{}
SegaCDIdentifier identifies Sega CD games.
func NewSegaCDIdentifier ¶
func NewSegaCDIdentifier() *SegaCDIdentifier
NewSegaCDIdentifier creates a new Sega CD identifier.
func (*SegaCDIdentifier) Console ¶
func (*SegaCDIdentifier) Console() Console
Console returns the console type.
func (*SegaCDIdentifier) Identify ¶
Identify extracts Sega CD game information from the given reader.
func (*SegaCDIdentifier) IdentifyFromPath ¶
func (s *SegaCDIdentifier) IdentifyFromPath(path string, database Database) (*Result, error)