1
0
Fork 0
mirror of https://github.com/Luzifer/sii.git synced 2024-12-21 08:21:16 +00:00
sii/cmd/save-clean/saves.go
Knut Ahlers 1753d98556
Implement save-game cleaner
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2020-01-05 13:56:10 +01:00

26 lines
665 B
Go

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
}