esmedia

package
v2.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package esmedia resolves local EmulationStation-style media folders and paths.

Index

Constants

This section is empty.

Variables

View Source
var ArtworkDirCandidates = map[string][]string{
	string(tags.TagPropertyImageImage): {"image", "images", "miximages", "custom"},
	string(tags.TagPropertyImageBoxart): {
		"boxart", "boxart2d", "box2d", "boxart2dfront", "box2dfront", "cover", "covers",
	},
	string(tags.TagPropertyImageBoxart3D):   {"boxart3d", "3dbox", "3dboxes"},
	string(tags.TagPropertyImageBoxartSide): {"boxart2dside"},
	string(tags.TagPropertyImageBoxartBack): {"boxart2dback", "backcover", "backcovers"},
	string(tags.TagPropertyImageScreenshot): {"screenshot", "screenshots"},
	string(tags.TagPropertyImageThumbnail): {
		"thumbnail", "thumbnails", "box2dfront", "boxart2dfront", "supporttexture",
	},
	string(tags.TagPropertyImageMarquee): {"marquee", "marquees"},
	string(tags.TagPropertyImageWheel):   {"wheel", "wheels", "logo", "logos"},
	string(tags.TagPropertyImageFanart):  {"fanart", "fanarts"},
	string(tags.TagPropertyImageTitleshot): {
		"titleshot", "titleshots", "titlescreen", "titlescreens", "screenshottitle",
	},
	string(tags.TagPropertyImageMap): {"map", "maps"},
}

ArtworkDirCandidates maps each TagPropertyImage value to ordered media sub-directory names under <systemRootPath>/media/.

View Source
var ArtworkExtensions = []string{".png", ".jpg", ".jpeg", ".webp"}

ArtworkExtensions are checked in order when deriving artwork filenames.

Functions

func ArtworkFallbackNames

func ArtworkFallbackNames(gamePath, systemRootPath string) []string

ArtworkFallbackNames returns candidate artwork filenames for gamePath under systemRootPath. For games in subdirectories, mirrored paths are checked before flat filenames.

func FallbackArtworkNames

func FallbackArtworkNames(stem string) []string

FallbackArtworkNames returns <stem> plus each supported artwork extension.

func IsHomeRelativePath

func IsHomeRelativePath(esPath string) bool

IsHomeRelativePath reports whether an ES path starts with ~/ or ~\.

func MimeFromExt

func MimeFromExt(path string) string

MimeFromExt returns a MIME type based on file extension.

func PathWithinRoot

func PathWithinRoot(path, root string) bool

PathWithinRoot reports whether path is inside root after absolute-path cleanup.

func ResolvePath

func ResolvePath(esPath, systemRootPath string) string

ResolvePath converts an EmulationStation path to an absolute path under systemRootPath. Paths that cannot be resolved or escape systemRootPath return an empty string.

func ResolvePathAbs

func ResolvePathAbs(esPath, systemRootPath string) (string, bool)

ResolvePathAbs converts an EmulationStation path to an absolute filesystem path without enforcing that the result stays inside systemRootPath.

func StatMediaDirs

func StatMediaDirs(rootPath string) map[string]string

StatMediaDirs reads <rootPath>/media and returns subdirectory name to path.

func StatMediaDirsFS

func StatMediaDirsFS(fs afero.Fs, rootPath string) map[string]string

StatMediaDirsFS reads <rootPath>/media using fs and returns subdirectory name to path.

Types

type File

type File struct {
	Path        string
	ContentType string
}

File is a local media file discovered in an EmulationStation media folder.

func FindFileAcrossRootsFS

func FindFileAcrossRootsFS(
	fs afero.Fs,
	fallbackNames []string,
	candidates []string,
	orderedAvailableDirs []map[string]string,
) *File

FindFileAcrossRootsFS searches each root's media directories in order and returns the first matching file. orderedAvailableDirs must be in priority order (RootDirs order); the first root with a hit wins. Within a root the existing candidate-directory order applies.

func FindFileFS

func FindFileFS(
	fs afero.Fs,
	fallbackNames []string,
	candidates []string,
	availableDirs map[string]string,
) *File

FindFileFS searches candidate directories for fallbackNames in order.

Jump to

Keyboard shortcuts

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