src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/mods/path/path.go (about) 1 // Package path provides functions for manipulating filesystem path names. 2 package path 3 4 import ( 5 "os" 6 "path/filepath" 7 8 "src.elv.sh/pkg/eval" 9 "src.elv.sh/pkg/eval/vars" 10 osmod "src.elv.sh/pkg/mods/os" 11 ) 12 13 // Ns is the namespace for the path: module. 14 var Ns = eval.BuildNsNamed("path"). 15 AddVars(map[string]vars.Var{ 16 "dev-null": vars.NewReadOnly(os.DevNull), 17 "dev-tty": vars.NewReadOnly(osmod.DevTTY), 18 "list-separator": vars.NewReadOnly(string(filepath.ListSeparator)), 19 "separator": vars.NewReadOnly(string(filepath.Separator)), 20 }). 21 AddGoFns(map[string]any{ 22 "abs": filepath.Abs, 23 "base": filepath.Base, 24 "clean": filepath.Clean, 25 "dir": filepath.Dir, 26 "ext": filepath.Ext, 27 "is-abs": filepath.IsAbs, 28 "join": filepath.Join, 29 30 // Compatibility aliases; these have moved to os: but are kept here 31 // until we can properly emit deprecation messages. 32 "eval-symlinks": filepath.EvalSymlinks, 33 "is-dir": osmod.IsDir, 34 "is-regular": osmod.IsRegular, 35 "temp-dir": osmod.TempDir, 36 "temp-file": osmod.TempFile, 37 }).Ns()