~welt/murse

99a7b574cfb6bfb9e4737cc4e8f726c22842ad05 — welt 3 months ago 5ceabbd
potential fix for windows path errors
4 files changed, 13 insertions(+), 10 deletions(-)

M download.go
M files.go
M flags.go
M main.go
M download.go => download.go +1 -1
@@ 57,7 57,7 @@ func get(url string) (*[]byte, error) {

func downloadAndVerify(path string, checksum string, lchecksum *string) error {
	log.Println(path)
	ff := opt.Directory + "/" + path
	ff := filepath.Join(opt.Directory, path)
	if _, err := os.Stat(ff); !os.IsNotExist(err) {
		b, err := os.ReadFile(ff)
		if err != nil {

M files.go => files.go +3 -2
@@ 5,6 5,7 @@ import (
	"database/sql"
	"log"
	"os"
	"path/filepath"
	"strings"
)



@@ 15,7 16,7 @@ func init() {
	}

	if !fileExists(cd) {
		err = os.MkdirAll(cd+"/murse", 0777)
		err = os.MkdirAll(filepath.Join(cd, "murse"), 0777)
		if err != nil {
			log.Fatal(err)
		}


@@ 28,7 29,7 @@ func getKey() (*rsa.PublicKey, error) {
		return nil, err
	}

	f := cd + "/murse/public.key"
	f := cd + filepath.Join(cd, "public.key")
	if fileExists(f) {
		b, err := os.ReadFile(f)
		if err != nil {

M flags.go => flags.go +3 -2
@@ 3,6 3,7 @@ package main
import (
	"log"
	"os"
	"path/filepath"
	"runtime"

	"github.com/jessevdk/go-flags"


@@ 25,8 26,8 @@ func init() {
		os.Exit(1)
	}

	lmd = opt.Directory + "/.murse/local.json"
	lfd = opt.Directory + "/.murse/lockfile"
	lmd = filepath.Join(opt.Directory, ".murse", "local.json")
	lfd = filepath.Join(opt.Directory, ".murse", "lockfile")
}

func init() {

M main.go => main.go +6 -5
@@ 5,6 5,7 @@ import (
	"database/sql"
	"log"
	"os"
	"path/filepath"
)

// If this is set we're doing a first-time installation


@@ 36,7 37,7 @@ func main() {
	// performance. Instead we verify the database and then trust its
	// hashes.
	if !opt.DisableSigning {
		ms, err := get(opt.URL + "/ofmanifest.sig")
		ms, err := get(opt.URL + "ofmanifest.sig")
		if err != nil {
			log.Fatal(err)
		}


@@ 50,8 51,8 @@ func main() {
		log.Fatal("Failed to determine cache directory: " + err.Error())
	}

	mcd := cd + "/murse/"
	tf := mcd + "/manifest.db"
	mcd := filepath.Join(cd)
	tf := filepath.Join(mcd, "ofmanifest.db")

	err = os.WriteFile(tf, *m, 0777)
	if err != nil {


@@ 97,7 98,7 @@ func main() {
		}
	}

	confdir := opt.Directory + "/.murse"
	confdir := filepath.Join(opt.Directory, ".murse")

	if !fileExists(confdir) {
		err := os.Mkdir(confdir, 0700)


@@ 142,7 143,7 @@ func main() {
			log.Fatal("Unable to download gameinfo.txt, game will not start: " + err.Error())
		}

		err = os.WriteFile(opt.Directory+"/gameinfo.txt", *b, 0777)
		err = os.WriteFile(filepath.Join(opt.Directory, "gameinfo.txt"), *b, 0777)
		if err != nil {
			log.Fatal("Failed to write gameinfo.txt to disk: " + err.Error())
		}