fix path so ini file can be found in users home directory
Signed-off-by: John Thornton <bjt128@gmail.com>
This commit is contained in:
14
dxf2gcode.go
14
dxf2gcode.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"math"
|
"math"
|
||||||
@ -17,8 +18,9 @@ func check(e error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func iniRead(m map[string]string) {
|
func iniRead(m map[string]string, home string) {
|
||||||
f, err := os.Open("dxf2gcode.ini")
|
home += "/dxf2gcode.ini"
|
||||||
|
f, err := os.Open(home)
|
||||||
check(err)
|
check(err)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
@ -214,6 +216,8 @@ start point.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main(){
|
func main(){
|
||||||
|
usr, err := user.Current()
|
||||||
|
check(err)
|
||||||
iniMap := make(map[string]string)
|
iniMap := make(map[string]string)
|
||||||
var inFile string
|
var inFile string
|
||||||
if len(os.Args) == 2 {
|
if len(os.Args) == 2 {
|
||||||
@ -225,17 +229,15 @@ func main(){
|
|||||||
inFile = os.Args[1]
|
inFile = os.Args[1]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//inFile = "test.dxf"
|
|
||||||
pwd, err := os.Getwd()
|
pwd, err := os.Getwd()
|
||||||
check(err)
|
check(err)
|
||||||
fmt.Println("Current Working Directory is:", pwd)
|
fmt.Println("Current Working Directory is:", pwd)
|
||||||
|
fmt.Println("Current User Directory is:", usr.HomeDir)
|
||||||
fmt.Println("Usage is: dxf2g filename.ext")
|
fmt.Println("Usage is: dxf2g filename.ext")
|
||||||
fmt.Println("Usage is: dxf2g -v")
|
fmt.Println("Usage is: dxf2g -v")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
iniRead(iniMap)
|
iniRead(iniMap, usr.HomeDir)
|
||||||
fmt.Println(iniMap)
|
|
||||||
fmt.Println(iniMap["SAVEAS"])
|
|
||||||
var entities []Ent
|
var entities []Ent
|
||||||
lines := getLines(inFile)
|
lines := getLines(inFile)
|
||||||
entities = getEnt(lines, entities)
|
entities = getEnt(lines, entities)
|
||||||
|
Reference in New Issue
Block a user