refactor: storage interface

This commit is contained in:
Ilia Denisov
2026-03-13 16:50:13 +02:00
parent 0862dbd1ba
commit 5328f149ed
3 changed files with 30 additions and 23 deletions
-22
View File
@@ -1,9 +1,7 @@
package storage
import (
"errors"
"fmt"
"galaxy/util"
"path/filepath"
)
@@ -15,26 +13,6 @@ const (
gameDataFileSuffix = ".dat"
)
type storage struct {
root string
}
// NewStorage returns implementation of the "galaxy/client.Storage" interface
// or nil with a non-nil error when filesystem storage initialisation failed.
func NewStorage(rootPath string) (*storage, error) {
ok, err := util.Writable(rootPath)
if err != nil {
return nil, err
}
if !ok {
return nil, errors.New("user does not have write permissions to the storage root")
}
s := &storage{
root: rootPath,
}
return s, nil
}
// StateFilePath returns client's state file path relative to the root,
// file name and extension are pre-defined constant.
func StateFilePath(root string) string {