refactor: storage interface

This commit is contained in:
Ilia Denisov
2026-03-13 17:30:39 +02:00
parent d7e12cbee0
commit 43039a79bf
3 changed files with 61 additions and 42 deletions
-26
View File
@@ -1,26 +0,0 @@
package storage
import (
"fmt"
"path/filepath"
)
const (
// Name of the file under the storage's root where [model.State] is stored.
stateFileName = "state.dat"
// Suffix of a Game's file inder the storage's root where [model.GameData] is stored.
gameDataFileSuffix = ".dat"
)
// StateFilePath returns client's state file path relative to the root,
// file name and extension are pre-defined constant.
func StateFilePath(root string) string {
return filepath.Join(root, stateFileName)
}
// GameDataPath returns game's data file path relative to the root,
// data file name is GameID string representation and extension is a pre-defined constant.
func GameDataFilePath(root string, id fmt.Stringer) string {
return filepath.Join(root, id.String()) + gameDataFileSuffix
}