Files
hakurei/internal/path.go
2025-07-02 21:23:55 +09:00

34 lines
667 B
Go

package internal
import (
"log"
"path"
"git.gensokyo.uk/security/hakurei/internal/hlog"
)
var (
hmain = compPoison
hsu = compPoison
)
func MustHakureiPath() string {
if name, ok := checkPath(hmain); ok {
return name
}
hlog.BeforeExit()
log.Fatal("invalid hakurei path, this program is compiled incorrectly")
return compPoison // unreachable
}
func MustHsuPath() string {
if name, ok := checkPath(hsu); ok {
return name
}
hlog.BeforeExit()
log.Fatal("invalid hsu path, this program is compiled incorrectly")
return compPoison // unreachable
}
func checkPath(p string) (string, bool) { return p, p != compPoison && p != "" && path.IsAbs(p) }