packwiz/core/resolve.go
2019-04-25 19:22:02 +01:00

28 lines
716 B
Go

package core
import (
"path/filepath"
"strings"
)
// ModExtension is the file extension of the mod metadata files
const ModExtension = ".toml"
// ResolveMod returns the path to a mod file from it's name
func ResolveMod(modName string, flags Flags) string {
fileName := strings.ToLower(strings.TrimSuffix(modName, ModExtension)) + ModExtension
return filepath.Join(flags.ModsFolder, fileName)
}
// ResolveIndex returns the path to the index file
func ResolveIndex(flags Flags) (string, error) {
pack, err := LoadPack(flags)
if err != nil {
return "", err
}
if filepath.IsAbs(pack.Index.File) {
return pack.Index.File, nil
}
return filepath.Join(filepath.Dir(flags.PackFile), pack.Index.File), nil
}