identifier

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package identifier provides console-specific game identification logic.

Index

Constants

This section is empty.

Variables

AllConsoles is a list of all supported consoles.

Functions

func ValidateGB

func ValidateGB(header []byte) bool

ValidateGB checks if the given data looks like a valid GB/GBC ROM.

func ValidateGBA

func ValidateGBA(header []byte) bool

ValidateGBA checks if the given data looks like a valid GBA ROM.

func ValidateGC

func ValidateGC(header []byte) bool

ValidateGC checks if the given data looks like a valid GameCube disc.

func ValidateGenesis

func ValidateGenesis(data []byte) bool

ValidateGenesis checks if the given data looks like a valid Genesis ROM.

func ValidateN64

func ValidateN64(header []byte) bool

ValidateN64 checks if the given data looks like a valid N64 ROM.

func ValidateSNES

func ValidateSNES(data []byte) bool

ValidateSNES checks if the given data looks like a valid SNES ROM.

func ValidateSaturn

func ValidateSaturn(header []byte) bool

ValidateSaturn checks if the given data looks like a valid Saturn disc.

func ValidateSegaCD

func ValidateSegaCD(header []byte) bool

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 FileInfo

type FileInfo struct {
	Path   string
	Offset int64
	Size   int64
}

FileInfo contains information about a file in an ISO filesystem.

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.

func (*GBAIdentifier) Identify

func (*GBAIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts GBA game information from the given reader.

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.

func (*GBIdentifier) Identify

func (g *GBIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts GB/GBC game information from the given reader.

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) Identify

func (*GCIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts GameCube game information from the given reader.

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.

func (*GenesisIdentifier) Identify

func (*GenesisIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts Genesis game information from the given reader.

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

type InvalidFormatError struct {
	Console Console
	Reason  string
}

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.

func (*N64Identifier) Identify

func (*N64Identifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts N64 game information from the given reader.

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.

func (*NESIdentifier) Identify

func (*NESIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts NES game information from the given reader.

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

func (*NeoGeoCDIdentifier) Identify(_ io.ReaderAt, _ int64, _ Database) (*Result, error)

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

func (*PS2Identifier) Identify(_ io.ReaderAt, _ int64, _ Database) (*Result, error)

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

func (*PSPIdentifier) Identify(_ io.ReaderAt, _ int64, _ Database) (*Result, error)

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

func (*PSXIdentifier) Identify(_ io.ReaderAt, _ int64, _ Database) (*Result, error)

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 NewResult

func NewResult(console Console) *Result

NewResult creates a new Result with initialized metadata map.

func (*Result) MergeMetadata

func (r *Result) MergeMetadata(dbEntry map[string]string)

MergeMetadata merges database metadata into the result. Database values only fill in missing fields.

func (*Result) MergeMetadataPreferDB

func (r *Result) MergeMetadataPreferDB(dbEntry map[string]string)

MergeMetadataPreferDB merges database metadata into the result. Database values overwrite extracted values.

func (*Result) SetMetadata

func (r *Result) SetMetadata(key, value string)

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.

func (*SNESIdentifier) Identify

func (*SNESIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts SNES game information from the given reader.

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

func (s *SaturnIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

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

func (s *SegaCDIdentifier) Identify(reader io.ReaderAt, size int64, db Database) (*Result, error)

Identify extracts Sega CD game information from the given reader.

func (*SegaCDIdentifier) IdentifyFromPath

func (s *SegaCDIdentifier) IdentifyFromPath(path string, database Database) (*Result, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL