add external/internal data options

"make all" will build with internal data, whereas "make debug"/"make
all-external" will make an external "data/" directory.
This commit is contained in:
Harvey Tindall
2021-02-01 20:25:20 +00:00
parent 815bdc35ac
commit 72cf3e2240
8 changed files with 91 additions and 43 deletions

View File

@@ -1,7 +1,6 @@
package main
import (
"fmt"
"io/fs"
"net/http"
"strings"
@@ -15,13 +14,12 @@ type httpFS struct {
}
func (f httpFS) Open(name string) (http.File, error) {
fmt.Println("build/data/web" + name)
return f.hfs.Open("build/data/web" + name)
return f.hfs.Open("data/web" + name)
}
func (f httpFS) Exists(prefix string, filepath string) bool {
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
stats, err := fs.Stat(f.fs, "build/data/web/"+p)
stats, err := fs.Stat(f.fs, "data/web/"+p)
if err != nil {
return false
}