fix for windows

This commit is contained in:
2023-07-12 00:43:18 +01:00
parent 4d37d8d4de
commit 32f810e9b0
3 changed files with 6 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ func importMod(realpath string, origin string, main bool, global ArObject) (ArOb
if err != nil {
return ArObject{}, ArErr{TYPE: "Import Error", message: "Could not get executable", EXISTS: true}
}
executable := filepath.Dir(exc)
executable := filepath.Dir(filepath.ToSlash(exc))
isABS := filepath.IsAbs(path)
var pathsToTest []string
if isABS {
@@ -127,7 +127,7 @@ func importMod(realpath string, origin string, main bool, global ArObject) (ArOb
if _, ok := args[0].(string); !ok {
return nil, ArErr{"Import Error", "Invalid argument type", 0, realpath, "", true}
}
return importMod(args[0].(string), filepath.Dir(p), false, global)
return importMod(args[0].(string), filepath.Dir(filepath.ToSlash(p)), false, global)
}},
"cwd": ex,
"exc": exc,

View File

@@ -86,7 +86,7 @@ func runImport(importOBJ ArImport, stack stack, stacklevel int) (any, ArErr) {
return nil, ArErr{"Type Error", "import requires a string, got type '" + typeof(val) + "'", importOBJ.Line, importOBJ.Path, importOBJ.Code, true}
}
path := val.(string)
parent := filepath.Dir(importOBJ.Path)
parent := filepath.Dir(filepath.ToSlash(importOBJ.Path))
stackMap, err := importMod(path, parent, false, stack[0])
if err.EXISTS {
if err.line == 0 {

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"
)
var ArPath = Map(
@@ -65,7 +66,7 @@ var ArPath = Map(
}
Path = append(Path, x.(string))
}
return path.Join(Path...), ArErr{}
return filepath.Join(Path...), ArErr{}
}
return nil, ArErr{
TYPE: "runtime",
@@ -91,7 +92,7 @@ var ArPath = Map(
EXISTS: true,
}
}
return path.Dir(args[0].(string)), ArErr{}
return path.Dir(filepath.ToSlash(args[0].(string))), ArErr{}
},
},
})