From 32f810e9b011b041d15e7c59d978709b746e01c2 Mon Sep 17 00:00:00 2001 From: Ugric Date: Wed, 12 Jul 2023 00:43:18 +0100 Subject: [PATCH] fix for windows --- src/import.go | 4 ++-- src/parseImport.go | 2 +- src/path.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/import.go b/src/import.go index 7eafd8c..d8d3e50 100644 --- a/src/import.go +++ b/src/import.go @@ -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, diff --git a/src/parseImport.go b/src/parseImport.go index d478a4c..ad47cb8 100644 --- a/src/parseImport.go +++ b/src/parseImport.go @@ -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 { diff --git a/src/path.go b/src/path.go index 1ce3467..44e48ed 100644 --- a/src/path.go +++ b/src/path.go @@ -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{} }, }, })