mirror of
https://github.com/bluszcz/cutego.git
synced 2024-09-28 21:25:16 +03:00
40 lines
843 B
Go
40 lines
843 B
Go
package utils
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
func VIRTUALBOX_DIR() string {
|
|
if dir, ok := os.LookupEnv("VIRTUALBOX_DIR"); ok {
|
|
return filepath.Clean(dir)
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
return "C:\\Program Files\\Oracle\\VirtualBox"
|
|
}
|
|
path, err := exec.LookPath("vboxmanage")
|
|
if err != nil {
|
|
Log.WithError(err).Error("failed to find vboxmanage in your PATH")
|
|
}
|
|
path = filepath.Dir(path)
|
|
if !filepath.IsAbs(path) {
|
|
path, err = filepath.Abs(path)
|
|
if err != nil {
|
|
Log.WithError(err).WithField("path", path).Fatal("can't resolve absolute path")
|
|
}
|
|
}
|
|
return path
|
|
}
|
|
|
|
func SAILFISH_DIR() string {
|
|
if dir, ok := os.LookupEnv("SAILFISH_DIR"); ok {
|
|
return filepath.Clean(dir)
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
return "C:\\SailfishOS"
|
|
}
|
|
return filepath.Join(os.Getenv("HOME"), "SailfishOS")
|
|
}
|