cerrado @ v0.0.9

 1package u
 2
 3import (
 4	"errors"
 5	"log/slog"
 6	"os"
 7	"path/filepath"
 8)
 9
10func FileExist(filename string) bool {
11	if _, err := os.Stat(filename); err == nil {
12		return true
13
14	} else if errors.Is(err, os.ErrNotExist) {
15		return false
16	} else {
17		slog.Warn("Schrödinger's file: it may or may not exist", "file", filename) 
18		// Schrodinger: file may or may not exist. To be extra safe it will
19		// report the file doest not exist
20		return false
21	}
22}
23
24// This is just a slin wraper to make easier to compose path in the template
25type Pathing string
26
27func Root() Pathing {
28	return "/"
29}
30
31func (s Pathing) AddPath(p string) Pathing {
32	return Pathing(filepath.Join(string(s), p))
33}
34
35func (s Pathing) AddPaths(p []string) Pathing {
36	f := filepath.Join(p...)
37	return Pathing(filepath.Join(string(s), f))
38}
39
40func (s Pathing) Done() string {
41	return string(s)
42}