metadata

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metadata extracts mod metadata from well-known files inside a mod directory (e.g. 7 Days to Die's ModInfo.xml). Adding a format means adding one Reader implementation and listing it in readers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Name        string
	DisplayName string
	Version     string
	Summary     string
	Author      string
}

Info is metadata extracted from a well-known mod metadata file. Zero-value fields mean the file did not provide them.

func Resolve

func Resolve(modDir string) *Info

Resolve extracts metadata from modDir using the first matching reader. Returns nil when no known metadata file exists or it cannot be parsed; callers fall back to name-based detection.

func ResolveArchive

func ResolveArchive(archivePath string) *Info

ResolveArchive extracts metadata from a .zip or .jar archive whose ModInfo.xml lives at the archive root or exactly one directory deep - the common "wrapper folder" layout used by 7 Days to Die mods (e.g. a donovan-aio.zip containing donovan-aio/ModInfo.xml). Returns nil when the archive can't be opened, has no ModInfo.xml, or the metadata is malformed; callers fall back to filename-based detection, mirroring Resolve.

type ModInfoXML

type ModInfoXML struct{}

ModInfoXML reads 7 Days to Die ModInfo.xml files. Two layouts exist: V2 puts fields directly under <xml>; V1 nests them in <ModInfo>.

func (ModInfoXML) Detect

func (ModInfoXML) Detect(modDir string) string

Detect implements Reader. Matching is case-insensitive (strings.EqualFold) to mirror findModInfoEntry's archive-path handling: some mod packagers ship lowercase modinfo.xml, and Linux filesystems are case-sensitive so an exact os.Stat would miss it.

func (ModInfoXML) Read

func (ModInfoXML) Read(path string) (*Info, error)

Read implements Reader.

type Reader

type Reader interface {
	// Detect returns the metadata file path within modDir, or "" if absent.
	Detect(modDir string) string
	// Read parses the metadata file at path.
	Read(path string) (*Info, error)
}

Reader parses one well-known metadata file format.

Jump to

Keyboard shortcuts

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