|
|
@@ -47,6 +47,14 @@ func SetOptDirs(cfgEnabled, runEnabled, varEnabled, imgEnabled bool) {
|
|
|
}
|
|
|
|
|
|
func InitPath() {
|
|
|
+ initPath(false)
|
|
|
+}
|
|
|
+
|
|
|
+func InitPathReal() {
|
|
|
+ initPath(true)
|
|
|
+}
|
|
|
+
|
|
|
+func initPath(resolveSymlink bool) {
|
|
|
file, err := exec.LookPath(os.Args[0])
|
|
|
if err != nil {
|
|
|
fmt.Printf("An error occurred while calling the exec.LookPath() function: %v\n", err)
|
|
|
@@ -59,6 +67,14 @@ func InitPath() {
|
|
|
os.Exit(1)
|
|
|
}
|
|
|
|
|
|
+ if resolveSymlink { // 解析符号链接
|
|
|
+ path, err = filepath.EvalSymlinks(path)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("An error occurred while calling the filepath.EvalSymlinks() function: %v\n", err)
|
|
|
+ os.Exit(1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
EXEC_DIR = filepath.Dir(path)
|
|
|
EXEC_FILENAME = filepath.Base(path)
|
|
|
|