1
0
Fork 0
mirror of https://github.com/Luzifer/sii.git synced 2024-12-22 00:41:16 +00:00
sii/cmd/save-clean/saves.go

27 lines
665 B
Go
Raw Normal View History

package main
import (
"path"
"github.com/pkg/errors"
"github.com/Luzifer/sii"
)
// loadSave reads game- and info- unit and returns them unmodified
func loadSave(gameSIIPath string) (*sii.Unit, error) {
gameUnit, err := sii.ReadUnitFile(gameSIIPath)
return gameUnit, errors.Wrap(err, "Unable to load save-unit")
}
// storeSave writes game- and info- unit without checking for existance!
func storeSave(gameSIIPath string, unit *sii.Unit) error {
var saveUnitPath = path.Join(path.Dir(gameSIIPath), "game.cleaned.sii")
if err := sii.WriteUnitFile(saveUnitPath, unit); err != nil {
return errors.Wrap(err, "Unable to write game unit")
}
return nil
}