From 23174e1f56fcee79a65c122e8970661c2afe9a6d Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Thu, 26 Aug 2021 11:38:55 +1000 Subject: [PATCH] use filepath.Base --- engine/asset.go | 4 +++- game/assets/level1.gobz | Bin 1214 -> 1214 bytes main.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engine/asset.go b/engine/asset.go index 40fd21e..b663fba 100644 --- a/engine/asset.go +++ b/engine/asset.go @@ -5,6 +5,7 @@ import ( "encoding/gob" "io/fs" "os" + "path/filepath" ) type assetKey struct { @@ -12,6 +13,7 @@ type assetKey struct { path string } +// LoadGobz gunzips and gob-decodes a component from a file from a FS. func LoadGobz(dst interface{}, assets fs.FS, path string) error { f, err := assets.Open(path) if err != nil { @@ -28,7 +30,7 @@ func LoadGobz(dst interface{}, assets fs.FS, path string) error { // SaveGobz takes an object, gob-encodes it, gzips it, and writes to disk. // This requires running on something with a disk to write to (not JS) func SaveGobz(src interface{}, name string) error { - f, err := os.CreateTemp(".", name) + f, err := os.CreateTemp(".", filepath.Base(name)) if err != nil { return err } diff --git a/game/assets/level1.gobz b/game/assets/level1.gobz index 6edfbdb38fb35bf2dd75242424a6e9230dcf0622..60736db024d2cd6e3467fe919d29d615932ee039 100644 GIT binary patch literal 1214 zcmV;v1VQ^BiwFP!00000|EySFZxmG&KfgQE-RZI}>t<6orNUZC6N%aCt1ktLD2YuQ zmIslL=63gXJ2E@d%nVR5B#Md(h>D7ciumV4_~;{vPksZwfqsHL=1%{xMb_*|`!cC8FJ?>oRqvt>d9zCy@Boj8UfA$K%7AGQwdd!!fg1~eB3rMJR+Ln4;*Z>qTtN=A^0l6nbT`_Ky-jVvJNanewb!U z3V0JP0jJ>-(FA|2fYO<>ewdngS+`96-OHI1Wugmw1^K{SFu~%>0A?^lKu`UFo~jce z|7<&cJ4#j>ZF6C|b3X0_X4-@uKQxWweh~1d4&d4m_!`08jC^D^3ZfY0fuZqTzII5J z{jTnq>6QgIUW@fReBIi!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main.go +++ b/main.go @@ -145,7 +145,7 @@ func writeLevel1() { }, } - if err := engine.SaveGobz(level1, "level1.gobz"); err != nil { + if err := engine.SaveGobz(level1, "game/assets/level1.gobz"); err != nil { log.Fatalf("Couldn't save level1.gobz: %v", err) }