mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
fix minor dir bug
This commit is contained in:
@@ -2,8 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
@@ -14,21 +12,16 @@ var importing = make(map[string]bool)
|
|||||||
const modules_folder = "argon_modules"
|
const modules_folder = "argon_modules"
|
||||||
|
|
||||||
func FileExists(filename string) bool {
|
func FileExists(filename string) bool {
|
||||||
if _, err := os.Stat(filename); err == nil {
|
if info, err := os.Stat(filename); err == nil && !info.IsDir() {
|
||||||
return true
|
return true
|
||||||
|
|
||||||
} else if errors.Is(err, os.ErrNotExist) {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFile(path string) []UNPARSEcode {
|
func readFile(path string) ([]UNPARSEcode, error) {
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
@@ -43,10 +36,9 @@ func readFile(path string) []UNPARSEcode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return output
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func importMod(realpath string, origin string, main bool, global ArObject) (ArObject, ArErr) {
|
func importMod(realpath string, origin string, main bool, global ArObject) (ArObject, ArErr) {
|
||||||
@@ -63,7 +55,7 @@ func importMod(realpath string, origin string, main bool, global ArObject) (ArOb
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ArObject{}, ArErr{TYPE: "Import Error", message: "Could not get executable", EXISTS: true}
|
return ArObject{}, ArErr{TYPE: "Import Error", message: "Could not get executable", EXISTS: true}
|
||||||
}
|
}
|
||||||
executable := filepath.Dir(filepath.ToSlash(exc))
|
executable := filepath.Dir(exc)
|
||||||
isABS := filepath.IsAbs(path)
|
isABS := filepath.IsAbs(path)
|
||||||
var pathsToTest []string
|
var pathsToTest []string
|
||||||
if isABS {
|
if isABS {
|
||||||
@@ -101,7 +93,10 @@ func importMod(realpath string, origin string, main bool, global ArObject) (ArOb
|
|||||||
return imported[p], ArErr{}
|
return imported[p], ArErr{}
|
||||||
}
|
}
|
||||||
importing[p] = true
|
importing[p] = true
|
||||||
codelines := readFile(p)
|
codelines, err := readFile(p)
|
||||||
|
if err != nil {
|
||||||
|
return ArObject{}, ArErr{TYPE: "Import Error", message: "Could not read file: " + path, EXISTS: true}
|
||||||
|
}
|
||||||
translated, translationerr := translate(codelines)
|
translated, translationerr := translate(codelines)
|
||||||
|
|
||||||
if translationerr.EXISTS {
|
if translationerr.EXISTS {
|
||||||
|
|||||||
Reference in New Issue
Block a user