diff --git a/src/import.go b/src/import.go index ded69ae..8f67dc7 100644 --- a/src/import.go +++ b/src/import.go @@ -73,18 +73,17 @@ func importMod(realpath string, origin string, main bool, global ArObject) (ArOb } } else { pathsToTest = []string{ - filepath.Join(origin, realpath, "init.ar"), filepath.Join(origin, path), + filepath.Join(origin, realpath, "init.ar"), filepath.Join(origin, modules_folder, path), filepath.Join(origin, modules_folder, realpath, "init.ar"), filepath.Join(ex, path), - filepath.Join(ex, modules_folder, realpath, "init.ar"), filepath.Join(ex, modules_folder, path), - filepath.Join(executable, modules_folder, realpath, "init.ar"), + filepath.Join(ex, modules_folder, realpath, "init.ar"), filepath.Join(executable, modules_folder, path), + filepath.Join(executable, modules_folder, realpath, "init.ar"), } } - var p string var found bool for _, p = range pathsToTest { diff --git a/src/parseImport.go b/src/parseImport.go index 448d016..89d22a7 100644 --- a/src/parseImport.go +++ b/src/parseImport.go @@ -1,7 +1,7 @@ package main import ( - "os" + "path/filepath" "strings" ) @@ -84,11 +84,8 @@ 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) - ex, e := os.Getwd() - if e != nil { - return nil, ArErr{"File Error", "could not get current working directory", importOBJ.line, importOBJ.path, importOBJ.code, true} - } - stackMap, err := importMod(path, ex, false, stack[0]) + parent := filepath.Dir(importOBJ.path) + stackMap, err := importMod(path, parent, false, stack[0]) if err.EXISTS { if err.line == 0 { err.line = importOBJ.line diff --git a/src/socket.go b/src/socket.go index e1eedfc..3eedb52 100644 --- a/src/socket.go +++ b/src/socket.go @@ -127,5 +127,11 @@ func ArSocket(args ...any) (any, ArErr) { return nil, ArErr{} }, }, + "isClosed": builtinFunc{ + "isClosed", + func(args ...any) (any, ArErr) { + return ln == nil, ArErr{} + }, + }, }), ArErr{} }