HOW DO THE FUCK THE PATHS WORK ON WINDOWS?

This commit is contained in:
Andrey Parhomenko 2023-03-08 22:26:23 +03:00
parent afa0e736bd
commit da2a5042e9
5 changed files with 39 additions and 31 deletions

View file

@ -8,12 +8,13 @@ install-sh:VQ: build
if test -d app ; then if test -d app ; then
echo Installing application files... echo Installing application files...
echo "'$APPDIR'" echo "'$APPDIR'"
mkdir -p $APPDIR/$PKG_NAME && cp -rf app/* $APPDIR/$PKG_NAME/ echo `goblin paths app/* $APPDIR/$PKG_NAME/`
#goblin mkdir -p `goblin path $APPDIR/$PKG_NAME` && cp -rf `goblin paths app/* $APPDIR/$PKG_NAME/`
echo Done installing application files echo Done installing application files
fi fi
if test -d exe ; then if test -d exe ; then
echo Installing executables... echo Installing executables...
mkdir -p $EXEDIR goblin mkdir -p $EXEDIR
cp -rf exe/* $EXEDIR/ cp -rf exe/* $EXEDIR/
files=`goblin basename $(ls exe)` files=`goblin basename $(ls exe)`
for i in $files ; do for i in $files ; do

View file

@ -4,6 +4,7 @@ package pathx
// paths. // paths.
import ( import (
//"fmt"
"path" "path"
fp "path/filepath" fp "path/filepath"
"strings" "strings"
@ -28,10 +29,10 @@ func From(p string) Path {
return ret return ret
} }
/* p = path.Clean(p) p = path.Clean(p)
if p[0] == '/' { if p[0] == '/' {
ret.IsAbs = true ret.IsAbs = true
} */ }
p, _ = strings.CutSuffix(p, "/") p, _ = strings.CutSuffix(p, "/")
svalues := strings.Split(p, "/") svalues := strings.Split(p, "/")
@ -45,7 +46,9 @@ func From(p string) Path {
} }
func FromReal(p string) Path { func FromReal(p string) Path {
return From(fp.ToSlash(p)) ret := From(fp.ToSlash(p))
//fmt.Println("from real:", ret)
return ret
} }
func (v Value) IsValid() bool { func (v Value) IsValid() bool {

View file

@ -174,7 +174,6 @@ func parseRedirInclude(p *parser, t token) parserStateFun {
file, err := os.Open(pths.Real()) file, err := os.Open(pths.Real())
if err != nil { if err != nil {
p.basicWarnAtToken(fmt.Sprintf("cannot open %s", filename), p.tokenbuf[0]) p.basicWarnAtToken(fmt.Sprintf("cannot open %s", filename), p.tokenbuf[0])
//fmt.Printf("%q %q %q\n", pths.Values, pths.Real(), pths.String())
//p.basicErrorAtToken(fmt.Sprintf("cannot open %s", filename), p.tokenbuf[0]) //p.basicErrorAtToken(fmt.Sprintf("cannot open %s", filename), p.tokenbuf[0])
} }
input, _ := io.ReadAll(file) input, _ := io.ReadAll(file)

View file

@ -1,9 +1,11 @@
package mkdir package mkdir
import( import (
"flag"
"fmt" "fmt"
"os" "os"
"flag"
"github.com/surdeus/goblin/src/pathx"
) )
func Run(args []string) { func Run(args []string) {
@ -11,7 +13,7 @@ func Run(args []string) {
args = args[1:] args = args[1:]
var ( var (
parentFlag bool parentFlag bool
modeArg int modeArg int
) )
flagSet := flag.NewFlagSet(arg0, flag.ExitOnError) flagSet := flag.NewFlagSet(arg0, flag.ExitOnError)
flagSet.BoolVar(&parentFlag, "p", false, "No error if existing, make parent as needed.") flagSet.BoolVar(&parentFlag, "p", false, "No error if existing, make parent as needed.")
@ -24,14 +26,16 @@ func Run(args []string) {
args = flagSet.Args() args = flagSet.Args()
if len(args) == 0 { if len(args) == 0 {
flagSet.Usage() flagSet.Usage()
os.Exit(1)
} }
mode := os.FileMode(modeArg) mode := os.FileMode(modeArg)
for _, path := range args { for _, path := range args {
var e error var e error
pth := pathx.From(path).Real()
if parentFlag { if parentFlag {
e = os.MkdirAll(path, mode) e = os.MkdirAll(pth, mode)
} else { } else {
e = os.Mkdir(path, mode) e = os.Mkdir(pth, mode)
} }
if e != nil { if e != nil {
fmt.Fprintf(os.Stderr, "%s: %s.\n", arg0, e) fmt.Fprintf(os.Stderr, "%s: %s.\n", arg0, e)

View file

@ -1,31 +1,33 @@
package paths package paths
import ( import (
"fmt"
"flag"
"bufio" "bufio"
"os"
"github.com/surdeus/goblin/src/pathx"
"path"
"log"
"errors" "errors"
"flag"
"fmt"
"log"
"os"
"path"
"github.com/surdeus/goblin/src/pathx"
) )
var ( var (
part string part string
handlers = map[string] func(string) string { handlers = map[string]func(string) string{
"base" : path.Base, "base": path.Base,
"ext" : path.Ext, "ext": path.Ext,
"dir" : path.Dir, "dir": path.Dir,
"all" : func(v string) string {return v}, "all": func(v string) string { return v },
"fr": func(v string) string {
return pathx.FromReal(v).String()
},
} }
handler func(string) string handler func(string) string
r bool r bool
noPartErr = errors.New("no such part") noPartErr = errors.New("no such part")
) )
func handlePath(p string) { func handlePath(p string) {
if handler != nil { if handler != nil {
p = handler(p) p = handler(p)
@ -63,4 +65,3 @@ func Run(args []string) {
handlePath(rd.Text()) handlePath(rd.Text())
} }
} }