mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Issue #13.
This commit is contained in:
@@ -9,9 +9,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "1.0.0"
|
const (
|
||||||
const extension = ".asl"
|
version = "1.0.0"
|
||||||
const sqfextension = ".sqf"
|
extension = ".asl"
|
||||||
|
sqfextension = ".sqf"
|
||||||
|
PathSeparator = string(os.PathSeparator)
|
||||||
|
)
|
||||||
|
|
||||||
type ASLFile struct {
|
type ASLFile struct {
|
||||||
in string
|
in string
|
||||||
@@ -69,12 +72,12 @@ func readAslFiles(path string) {
|
|||||||
name := dir[i].Name()
|
name := dir[i].Name()
|
||||||
|
|
||||||
if dir[i].IsDir() && recursive {
|
if dir[i].IsDir() && recursive {
|
||||||
readAslFiles(filepath.FromSlash(path+"/"+name))
|
readAslFiles(filepath.FromSlash(path+PathSeparator+name))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !dir[i].IsDir() && strings.ToLower(filepath.Ext(name)) == extension {
|
if !dir[i].IsDir() && strings.ToLower(filepath.Ext(name)) == extension {
|
||||||
in := filepath.FromSlash(path+"/"+dir[i].Name())
|
in := filepath.FromSlash(path+PathSeparator+dir[i].Name())
|
||||||
out := filepath.FromSlash("./"+path[len(inDir):len(path)])
|
out := filepath.FromSlash("./"+path[len(inDir):len(path)])
|
||||||
newname := name[:len(name)-len(filepath.Ext(name))]
|
newname := name[:len(name)-len(filepath.Ext(name))]
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ func readAslFiles(path string) {
|
|||||||
|
|
||||||
func compile(path string) {
|
func compile(path string) {
|
||||||
for i := 0; i < len(aslFiles); i++ {
|
for i := 0; i < len(aslFiles); i++ {
|
||||||
out := filepath.FromSlash(path+"/"+aslFiles[i].out+"/"+aslFiles[i].newname+sqfextension)
|
out := filepath.FromSlash(path+PathSeparator+aslFiles[i].out+PathSeparator+aslFiles[i].newname+sqfextension)
|
||||||
fmt.Println(aslFiles[i].in+" -> "+out)
|
fmt.Println(aslFiles[i].in+" -> "+out)
|
||||||
code, err := ioutil.ReadFile(aslFiles[i].in)
|
code, err := ioutil.ReadFile(aslFiles[i].in)
|
||||||
|
|
||||||
@@ -98,7 +101,7 @@ func compile(path string) {
|
|||||||
token := asl.Tokenize(code)
|
token := asl.Tokenize(code)
|
||||||
sqf := asl.Parse(token, pretty)
|
sqf := asl.Parse(token, pretty)
|
||||||
|
|
||||||
os.MkdirAll(filepath.FromSlash(path+"/"+aslFiles[i].out), 0777)
|
os.MkdirAll(filepath.FromSlash(path+PathSeparator+aslFiles[i].out), 0777)
|
||||||
err = ioutil.WriteFile(out, []byte(sqf), 0666)
|
err = ioutil.WriteFile(out, []byte(sqf), 0666)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user