go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 338acb33332b8429f7299b56da1b50a907c107d1
parent 3a657f48e068ce522e0a4d1eda81296bfcfd272e
Author: lash <dev@holbrook.no>
Date:   Sat, 31 Aug 2024 14:44:41 +0100

Include menu in gdbm directory scanner

Diffstat:
MCHANGELOG | 6++++--
Mdev/gdbm/main.go | 22+++++++++++++++++++---
2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,7 +1,9 @@ -- 0.1.15 +- 0.1.0 + * Data storage interface with implementations for memory, filesystem, gdbm and Postgres +- 0.0.15 * Add comprehensive documentation with texinfo. * Prevent cursor leak in sizer. -- 0.1.14 +- 0.0.14 * Add language support for menus. * Support for multi-page menus (only works for template renders without a sink). * Executable example for multi-page menus. diff --git a/dev/gdbm/main.go b/dev/gdbm/main.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "path" + "strings" gdbm "github.com/graygnuorg/go-gdbm" @@ -17,11 +18,16 @@ import ( var ( binaryPrefix = ".bin" + menuPrefix = "menu" templatePrefix = "" scan = make(map[string]string) + dbg = map[uint8]string{ + db.DATATYPE_BIN: "BIN", + db.DATATYPE_TEMPLATE: "TEMPLATE", + db.DATATYPE_MENU: "MENU", + } ) - type scanner struct { db *gdbm.Database } @@ -51,11 +57,21 @@ func(sc *scanner) Scan(fp string, d fs.DirEntry, err error) error { } fx := path.Ext(fp) fb := path.Base(fp) + if (len(fb) == 0) { + return nil + } + if (fb[0] < 0x61 || fb[0] > 0x7A) { + return nil + } switch fx { case binaryPrefix: typ = db.DATATYPE_BIN case templatePrefix: - typ = db.DATATYPE_TEMPLATE + if strings.Contains(fb, "_menu") { + typ = db.DATATYPE_TEMPLATE + } else { + typ = db.DATATYPE_MENU + } default: log.Printf("skip foreign file: %s", fp) return nil @@ -77,7 +93,7 @@ func(sc *scanner) Scan(fp string, d fs.DirEntry, err error) error { if err != nil { return err } - log.Printf("stored key %x for %s (%s)", k, fp, ft) + log.Printf("stored key [%s] %x for %s (%s)", dbg[typ], k, fp, ft) return nil }