WIP: misc fixes, start updating CF/MR export to use download system

This commit is contained in:
comp500
2022-05-20 18:13:43 +01:00
parent e73fa8c48a
commit 55f0e4a297
8 changed files with 182 additions and 223 deletions

View File

@@ -2,6 +2,7 @@ package core
import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
@@ -355,6 +356,20 @@ func (in Index) GetAllMods() []string {
return list
}
// LoadAllMods reads all metadata files into Mod structs
func (in Index) LoadAllMods() ([]*Mod, error) {
modPaths := in.GetAllMods()
mods := make([]*Mod, len(modPaths))
for i, v := range modPaths {
modData, err := LoadMod(v)
if err != nil {
return nil, fmt.Errorf("failed to read metadata file %s: %w", v, err)
}
mods[i] = &modData
}
return mods, nil
}
// GetFilePath attempts to get the path of the destination index file as it is stored on disk
func (in Index) GetFilePath(f IndexFile) string {
return filepath.Join(filepath.Dir(in.indexFile), filepath.FromSlash(f.File))