container

package
v2.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package container decides when a directory of indexed media collapses to a single logical launch target, such as a disc folder holding one cue sheet beside its bin tracks. The rule is shared by the MediaDB queries that resolve containers from SQL and by scrapers that resolve them from an in-memory media index, so both agree on what counts as one game.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MediaExt

func MediaExt(mediaPath string) string

MediaExt returns the lowercased extension of a slash-separated media path, including the leading dot, or an empty string when there is none.

func ParentDir

func ParentDir(path string) string

ParentDir returns the immediate browse parent of an indexed media path, including the trailing slash. Virtual media collapses to its scheme prefix because those paths have no directory hierarchy.

Indexed paths are normally stored forward-slashed, but one that reached the row from filepath.Join carries the host separator instead. Searching only for "/" would return nothing for those, and an empty parent resolves to no container at all, silently dropping folder artwork on Windows.

func SelectLaunchMedia

func SelectLaunchMedia(rows []database.Media) *database.Media

SelectLaunchMedia returns the single logical launch target for a directory's direct media rows, or nil when the set is ambiguous. A lone file is its own target; otherwise one m3u playlist or one cue sheet surrounded only by its companion files stands in for the set.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index answers container questions from a set of already-loaded media rows. Callers that hold a whole system's media in memory, such as scrapers, use it to resolve directories without issuing a query per candidate.

func NewIndex

func NewIndex(rows []database.Media) *Index

NewIndex builds a container index over rows. Missing media is excluded so the result matches what the equivalent MediaDB queries would return.

func (*Index) HasMedia

func (idx *Index) HasMedia(dirPath string) bool

HasMedia reports whether dirPath holds any direct media rows. It lets callers tell "not a directory we indexed" apart from "a directory that did not collapse".

func (*Index) Resolve

func (idx *Index) Resolve(dirPath string) *database.Media

Resolve returns the single logical launch target for dirPath, or nil when the directory holds nested media, holds nothing, or is ambiguous.

Jump to

Keyboard shortcuts

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