Documentation
¶
Overview ¶
Package gameid works out what a game file is from its own bytes: which console it belongs to, whether it's a game at all, what it calls itself, and how sure that is.
A file's extension is only a hint, and on old formats a poor one: .bin and .iso mean half a dozen consoles, .md is usually a text file, .dmg a Mac disk image and .vb source code. So nothing here trusts one. Every check reads a few fixed places in the file, and says in plain words what it found, so that a person can see why.
Files are hostile until proven otherwise. Reads are small and bounded, sizes in a file are checked before they're used, and nothing is ever decrypted: an encrypted file is only recognised as one, from what its headers say in the open.
The package knows consoles only by their ids, and has no dependencies beyond the standard library, so anything can use it.
Index ¶
- Constants
- func CheckFor(console string, r io.ReaderAt, size int64) (fits bool, why string)
- func DiscIn(stem string) (disc, total int, rest string)
- func IsSlug(stem string) bool
- func SerialIn(name string) string
- func TrackNumber(stem string) int
- func Unslug(stem string) string
- type Finding
- type Kind
- type Quality
- type Sheet
Constants ¶
const ( Sega32X = "32x" SegaCD = "segacd" Saturn = "saturn" GameCube = "gc" Wii = "wii" WiiU = "wiiu" PS3 = "ps3" Xbox = "xbox" Switch = "switch" ThreeDO = "3do" PCFX = "pcfx" NeoGeoCD = "neogeocd" CDI = "cdi" )
Consoles this package recognises that the server may not be able to play. They're still worth naming: "this is a Saturn disc" beats "this doesn't look like a game".
Variables ¶
This section is empty.
Functions ¶
func CheckFor ¶
CheckFor is for consoles whose cartridges have no header at all. It can't prove a file is for one of these, only say whether a file a folder says is for one could be.
func DiscIn ¶
DiscIn reads which disc of how many a name says it is, and what's left of the name without that: "Mega Game (Disc 2 of 3)" is 2, 3 and "Mega Game". 0 when it doesn't say.
func IsSlug ¶
IsSlug says a name was written for a web address, not a person: no spaces, and words joined by dashes.
func TrackNumber ¶
TrackNumber says which track of a disc a name is, or 0.
Types ¶
type Finding ¶
type Finding struct {
// Console is the console the bytes prove, or "".
Console string
Kind Kind
// Proof says what was seen, in words for a person.
Proof string
// Title and Serial are what the file calls itself, Region where it says it's from.
Title, Serial, Region string
// Encrypted: this file's headers say it's encrypted, or its contents can't be read
// the way they would be if they weren't. 3DS, Switch and Wii U files can be.
Encrypted bool
// NeedsKeys: it's encrypted, and that's how it's meant to be played. A standalone
// emulator decrypts it with keys the owner copied from their own console, so it's a
// game to list, not one that can't play. Only set along with Encrypted.
NeedsKeys bool
// NewOnly: a 3DS game that only runs on a New 3DS.
NewOnly bool
// Text: this is a text file, whatever it's called.
Text bool
// Media is what a compressed disc image says it holds: cd, dvd or gd.
Media string
}
Finding is what a file's bytes say about it.
func Sniff ¶
Sniff reads a file and says what it is. It costs a handful of small reads, plus one or two compressed blocks for a compressed disc.
type Kind ¶
type Kind string
Kind is what sort of thing a file is.
const ( // KindUnknown: nothing here could say. KindUnknown Kind = "" // KindGame is something a person plays. KindGame Kind = "game" // KindBIOS is a console's or a copier's start-up software. KindBIOS Kind = "bios" // KindUpdate patches a game someone already has. KindUpdate Kind = "update" // KindDLC is extra content for a game. KindDLC Kind = "dlc" // KindUtility is a test cartridge, a cheat device, a menu: it runs, but isn't a game. KindUtility Kind = "utility" // KindAudio is a music CD, a chiptune, or one audio track of a disc. KindAudio Kind = "audio" // KindData is one piece of a game that can't stand alone. KindData Kind = "data" // KindOther is anything else: text, a PC program, a film disc. KindOther Kind = "other" )
func ClassifyName ¶
ClassifyName says what a file's name, without its extension, says it is. Most names say nothing: "" means it's left to the bytes.
type Quality ¶
type Quality int
Quality is how good a copy a set's entry is, from what its name says.
const ( QualityClean Quality = iota // a plain dump of a released game QualityPrerelease // beta, demo, sample QualityTranslated // someone's translation QualityAltered // bad dump, overdump, trainer, fix QualityHack // someone's game built on this one QualityPD // homemade: demos, intros )
From best to worst.
type Sheet ¶
type Sheet struct {
// Files are every file it names that's inside its own folder, in order.
Files []string
// Data is the file holding the first data track: what a console reads.
Data string
// AudioOnly: every track is audio, so it's a music CD.
AudioOnly bool
// Missing are the files it names that aren't there.
Missing []string
}
Sheet is what one of these files lists.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fixture makes tiny files for tests that have the headers real games have and nothing else: no game's code or data, only the marks the checks in gameid look for.
|
Package fixture makes tiny files for tests that have the headers real games have and nothing else: no game's code or data, only the marks the checks in gameid look for. |