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
echo Installing application files...
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
fi
if test -d exe ; then
echo Installing executables...
mkdir -p $EXEDIR
goblin mkdir -p $EXEDIR
cp -rf exe/* $EXEDIR/
files=`goblin basename $(ls exe)`
for i in $files ; do

View file

@ -4,6 +4,7 @@ package pathx
// paths.
import (
//"fmt"
"path"
fp "path/filepath"
"strings"
@ -28,10 +29,10 @@ func From(p string) Path {
return ret
}
/* p = path.Clean(p)
if p[0] == '/' {
ret.IsAbs = true
} */
p = path.Clean(p)
if p[0] == '/' {
ret.IsAbs = true
}
p, _ = strings.CutSuffix(p, "/")
svalues := strings.Split(p, "/")
@ -45,7 +46,9 @@ func From(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 {

View file

@ -174,7 +174,6 @@ func parseRedirInclude(p *parser, t token) parserStateFun {
file, err := os.Open(pths.Real())
if err != nil {
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])
}
input, _ := io.ReadAll(file)

View file

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

View file

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