Documentation
¶
Index ¶
- Variables
- func AlphaMapKeys[V any](m map[string]V) []string
- func CachedCompile(pattern string) (*regexp.Regexp, error)
- func CachedMustCompile(pattern string) *regexp.Regexp
- func ConfigDir(pl platforms.Platform) string
- func Contains[T comparable](xs []T, x T) bool
- func CopyFile(sourcePath, destPath string) error
- func CreateVirtualPath(scheme, id, name string) string
- func DataDir(pl platforms.Platform) string
- func DoLaunch(cfg *config.Instance, pl platforms.Platform, ...) error
- func ExeDir() string
- func FilenameFromPath(p string) string
- func FindLauncher(cfg *config.Instance, pl platforms.Platform, path string) (platforms.Launcher, error)
- func GetAllLocalIPs() []string
- func GetFileSize(filePath string) (int64, error)
- func GetLocalIP() string
- func GetMd5Hash(filePath string) (string, error)
- func GetSerialDeviceList() ([]string, error)
- func HasSpace(s string) bool
- func HasUserDir() (string, bool)
- func InitLogging(pl platforms.Platform, writers []io.Writer) error
- func IsFalsey(s string) bool
- func IsServiceRunning(cfg *config.Instance) bool
- func IsTruthy(s string) bool
- func IsZip(filePath string) bool
- func ListZip(filePath string) ([]string, error)
- func MapKeys[K comparable, V any](m map[K]V) []K
- func MatchSystemFile(cfg *config.Instance, pl platforms.Platform, systemID string, path string) bool
- func MaybeJSON(data []byte) bool
- func ParseCustomLaunchers(pl platforms.Platform, customLaunchers []config.LaunchersCustom) []platforms.Launcher
- func PathIsLauncher(cfg *config.Instance, pl platforms.Platform, l *platforms.Launcher, ...) bool
- func PathToLaunchers(cfg *config.Instance, pl platforms.Platform, path string) []platforms.Launcher
- func RandSeq(n int) (string, error)
- func RandomElem[T any](xs []T) (T, error)
- func ScanSteamApps(steamDir string) ([]platforms.ScanResult, error)
- func ScanSteamShortcuts(steamDir string) ([]platforms.ScanResult, error)
- func SlugifyPath(filePath string) string
- func SlugifyString(input string) string
- func TokensEqual(a, b *tokens.Token) bool
- func WaitForInternet(maxTries int) bool
- func YesNoPrompt(label string, def bool) bool
- type LauncherCache
- func (lc *LauncherCache) GetAllLaunchers() []platforms.Launcher
- func (lc *LauncherCache) GetLaunchersBySystem(systemID string) []platforms.Launcher
- func (lc *LauncherCache) Initialize(pl platforms.Platform, cfg *config.Instance)
- func (lc *LauncherCache) Refresh(pl platforms.Platform, cfg *config.Instance)
- type PathInfo
- type RegexCache
- type Service
- type ServiceArgs
- type ServiceEntry
- type VirtualPathResult
Constants ¶
This section is empty.
Variables ¶
var GlobalLauncherCache = &LauncherCache{}
GlobalLauncherCache is the singleton instance used throughout the application.
var GlobalRegexCache = NewRegexCache()
GlobalRegexCache is the singleton instance used throughout the application
var ReURI = regexp.MustCompile(`^([a-zA-Z][a-zA-Z0-9+.-]*)://(.+)$`)
Functions ¶
func AlphaMapKeys ¶
func CachedMustCompile ¶
Convenience functions that use the global cache
func Contains ¶
func Contains[T comparable](xs []T, x T) bool
Contains returns true if slice contains value.
func CreateVirtualPath ¶
CreateVirtualPath creates a properly encoded virtual path for media Example: "kodi-show", "123", "Some Hot/Cold" -> "kodi-show://123/Some%20Hot%2FCold"
func DoLaunch ¶
func DoLaunch( cfg *config.Instance, pl platforms.Platform, setActiveMedia func(*models.ActiveMedia), launcher *platforms.Launcher, path string, ) error
DoLaunch launches the given path and updates the active media with it if it was successful.
func FilenameFromPath ¶
func FindLauncher ¶
func FindLauncher( cfg *config.Instance, pl platforms.Platform, path string, ) (platforms.Launcher, error)
FindLauncher takes a path and tries to find the best possible match for a launcher, taking into account any allowlist restrictions. Returns the launcher to be used.
func GetAllLocalIPs ¶
func GetAllLocalIPs() []string
GetAllLocalIPs returns all non-loopback private IPv4 addresses
func GetFileSize ¶
func GetLocalIP ¶
func GetLocalIP() string
func GetMd5Hash ¶
func GetSerialDeviceList ¶
func HasUserDir ¶
HasUserDir checks if a "user" directory exists next to the Zaparoo binary and returns true and the absolute path to it. This directory is used as a parent for all platform directories if it exists, for a portable install.
func IsServiceRunning ¶
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
MapKeys returns a list of all keys in a map.
func MatchSystemFile ¶
func MatchSystemFile( cfg *config.Instance, pl platforms.Platform, systemID string, path string, ) bool
MatchSystemFile returns true if a given path is for a given system. This function now uses the launcher cache for O(1) system lookup instead of O(n*m).
func ParseCustomLaunchers ¶
func PathIsLauncher ¶
func PathIsLauncher( cfg *config.Instance, pl platforms.Platform, l *platforms.Launcher, path string, ) bool
PathIsLauncher returns true if a given path matches against any of the criteria defined in a launcher.
func PathToLaunchers ¶
func PathToLaunchers( cfg *config.Instance, pl platforms.Platform, path string, ) []platforms.Launcher
PathToLaunchers is a reverse lookup to match a given path against all possible launchers in a platform. Returns all matched launchers.
func RandomElem ¶
RandomElem picks and returns a random element from a slice.
func ScanSteamApps ¶
func ScanSteamApps(steamDir string) ([]platforms.ScanResult, error)
func ScanSteamShortcuts ¶
func ScanSteamShortcuts(steamDir string) ([]platforms.ScanResult, error)
func SlugifyPath ¶
func SlugifyString ¶
func TokensEqual ¶
func WaitForInternet ¶
func YesNoPrompt ¶
Types ¶
type LauncherCache ¶
type LauncherCache struct {
// contains filtered or unexported fields
}
LauncherCache provides fast O(1) launcher lookups by system ID. This replaces the expensive O(n*m) pl.Launchers() calls in hot paths.
func (*LauncherCache) GetAllLaunchers ¶
func (lc *LauncherCache) GetAllLaunchers() []platforms.Launcher
GetAllLaunchers returns all cached launchers.
func (*LauncherCache) GetLaunchersBySystem ¶
func (lc *LauncherCache) GetLaunchersBySystem(systemID string) []platforms.Launcher
GetLaunchersBySystem returns all launchers for a specific system ID. Returns nil if no launchers found for the system.
func (*LauncherCache) Initialize ¶
func (lc *LauncherCache) Initialize(pl platforms.Platform, cfg *config.Instance)
Initialize builds the launcher cache from platform launchers. This should be called once at startup after custom launchers are loaded.
type PathInfo ¶
func GetPathInfo ¶
type RegexCache ¶
type RegexCache struct {
// contains filtered or unexported fields
}
RegexCache provides thread-safe caching of compiled regular expressions to avoid repeated compilation overhead during media scanning operations.
func NewRegexCache ¶
func NewRegexCache() *RegexCache
NewRegexCache creates a new RegexCache instance
func (*RegexCache) Clear ¶
func (rc *RegexCache) Clear()
Clear removes all cached patterns (useful for testing or memory management)
func (*RegexCache) Compile ¶
func (rc *RegexCache) Compile(pattern string) (*regexp.Regexp, error)
Compile compiles a regex pattern and caches it for future use. If the pattern is already cached, returns the cached version. Returns an error if the pattern cannot be compiled.
func (*RegexCache) MustCompile ¶
func (rc *RegexCache) MustCompile(pattern string) *regexp.Regexp
MustCompile compiles a regex pattern and caches it for future use. If the pattern is already cached, returns the cached version. Panics if the pattern cannot be compiled (same behavior as regexp.MustCompile).
func (*RegexCache) Size ¶
func (rc *RegexCache) Size() int
Size returns the number of cached patterns
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(args ServiceArgs) (*Service, error)
func (*Service) ServiceHandler ¶
type ServiceArgs ¶
type ServiceArgs struct {
Platform platforms.Platform
Entry ServiceEntry
NoDaemon bool
}
type ServiceEntry ¶
type VirtualPathResult ¶
VirtualPathResult holds parsed virtual path components
func ParseVirtualPathStr ¶
func ParseVirtualPathStr(virtualPath string) (result VirtualPathResult, err error)
ParseVirtualPathStr parses a virtual path and returns its components with string ID