mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-25 11:03:56 +00:00
create save dir before running
This commit is contained in:
parent
018c0c413b
commit
6a2ff3b4e2
2 changed files with 14 additions and 10 deletions
11
util/util.go
11
util/util.go
|
|
@ -75,15 +75,6 @@ func GetSavePath(roomID string) string {
|
|||
return savePath(roomID)
|
||||
}
|
||||
|
||||
// GetSRAMPath returns SRAM location of game based on roomID
|
||||
func GetSRAMPath(hash string) string {
|
||||
return homeDir + "/.nes/sram/" + hash + ".dat"
|
||||
}
|
||||
|
||||
func sramPath(hash string) string {
|
||||
return homeDir + "/.nes/sram/" + hash + ".dat"
|
||||
}
|
||||
|
||||
func savePath(hash string) string {
|
||||
return homeDir + "/.nes/save/" + hash + ".dat"
|
||||
return homeDir + "/.cr/save/" + hash + ".dat"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@ package worker
|
|||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/giongto35/cloud-game/util"
|
||||
"github.com/giongto35/cloud-game/webrtc"
|
||||
storage "github.com/giongto35/cloud-game/worker/cloud-storage"
|
||||
"github.com/giongto35/cloud-game/worker/room"
|
||||
|
|
@ -35,6 +38,10 @@ type Handler struct {
|
|||
|
||||
// NewHandler returns a new server
|
||||
func NewHandler(overlordHost string) *Handler {
|
||||
// Create offline storage folder
|
||||
createOfflineStorage()
|
||||
|
||||
// Init online storage
|
||||
onlineStorage := storage.NewInitClient()
|
||||
|
||||
return &Handler{
|
||||
|
|
@ -159,3 +166,9 @@ func (h *Handler) Close() {
|
|||
room.Close()
|
||||
}
|
||||
}
|
||||
func createOfflineStorage() {
|
||||
dir, _ := path.Split(util.GetSavePath("dummy"))
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
log.Println("Failed to create offline storage, err: ", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue