Documentation
¶
Overview ¶
Package esmedia resolves local EmulationStation-style media folders and paths.
Index ¶
- Variables
- func ArtworkFallbackNames(gamePath, systemRootPath string) []string
- func ContainerArtworkFallbackNames(gamePath, systemRootPath string) []string
- func DirectoryArtworkDirCandidates(propValue string) []string
- func DirectoryArtworkFallbackNames(directoryPath, systemRootPath string) []string
- func FallbackArtworkNames(stem string) []string
- func IsDiscFolderExt(ext string) bool
- func IsHomeRelativePath(esPath string) bool
- func MimeFromExt(path string) string
- func PathWithinRoot(path, root string) bool
- func ResolvePath(esPath, systemRootPath string) string
- func ResolvePathAbs(esPath, systemRootPath string) (string, bool)
- func StatMediaDirs(rootPath string) map[string]string
- func StatMediaDirsFS(fs afero.Fs, rootPath string) map[string]string
- type DirNames
- type File
Constants ¶
This section is empty.
Variables ¶
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/.
var ArtworkExtensions = []string{".png", ".jpg", ".jpeg", ".webp"}
ArtworkExtensions are checked in order when deriving artwork filenames.
Functions ¶
func ArtworkFallbackNames ¶
ArtworkFallbackNames returns candidate artwork filenames for gamePath under systemRootPath. For games in subdirectories, mirrored paths are checked before flat filenames.
func ContainerArtworkFallbackNames ¶ added in v2.17.0
ContainerArtworkFallbackNames returns candidate artwork filenames named after the directory holding gamePath rather than the file itself. EmulationStation stores art for a folder shown as one game under the folder's own name, so a disc folder whose inner file is named differently is only found this way.
The folder's own name is always offered first. A folder named with a disc extension, which is how ES-DE makes a multi-disc folder read as one game, also answers to the extensionless stem. Any other dot belongs to the name: "Sonic 3.0" is a folder called that, not "Sonic 3" with an extension, and stripping it hands the folder a neighbouring game's artwork.
func DirectoryArtworkDirCandidates ¶ added in v2.20.0
DirectoryArtworkDirCandidates returns the ordered media sub-directory names searched for a directory's own artwork of the given TagPropertyImage value. A folders directory holds pictures of folders only, so it is searched here and never for a game file.
func DirectoryArtworkFallbackNames ¶ added in v2.18.0
DirectoryArtworkFallbackNames returns candidate artwork filenames named after directoryPath. Nested paths are checked before flat names, matching ArtworkFallbackNames and EmulationStation media-folder layouts.
func FallbackArtworkNames ¶
FallbackArtworkNames returns <stem> plus each supported artwork extension.
func IsDiscFolderExt ¶ added in v2.19.0
IsDiscFolderExt reports whether ext is one EmulationStation uses to name a folder after the disc image or playlist it stands in for, or after the ScummVM game whose data it holds.
func IsHomeRelativePath ¶
IsHomeRelativePath reports whether an ES path starts with ~/ or ~\.
func MimeFromExt ¶
MimeFromExt returns a MIME type based on file extension.
func PathWithinRoot ¶
PathWithinRoot reports whether path is inside root after absolute-path cleanup.
func ResolvePath ¶
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 ¶
ResolvePathAbs converts an EmulationStation path to an absolute filesystem path without enforcing that the result stays inside systemRootPath.
func StatMediaDirs ¶
StatMediaDirs reads <rootPath>/media and returns subdirectory name to path.
Types ¶
type DirNames ¶ added in v2.20.0
type DirNames struct {
// contains filtered or unexported fields
}
DirNames remembers which names each directory holds, from one listing per directory, so a search for many candidate filenames does not stat each one. It only ever rules a name out: a name the listing has, in any letter case, is still confirmed with a stat, which keeps the answer the filesystem's own on case-sensitive and case-insensitive storage alike. The zero value is not usable; a nil *DirNames rules nothing out.
func NewDirNames ¶ added in v2.20.0
NewDirNames returns an empty cache over fs. It is not safe for concurrent use, and holds every name it has listed until it is dropped.
func (*DirNames) MayContain ¶ added in v2.20.0
MayContain reports whether dir can hold an entry called name. It is false only when dir was listed, or does not exist, and has no such entry.
type File ¶
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.
func FindFileIn ¶ added in v2.20.0
func FindFileIn( fs afero.Fs, names *DirNames, fallbackNames []string, candidates []string, availableDirs map[string]string, ) *File
FindFileIn is FindFileFS with a directory name cache, for a caller that searches the same directories for many files. names may be nil.