You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Xray-core/common/platform/others.go

45 lines
923 B

//go:build !windows
4 years ago
// +build !windows
package platform
import (
"os"
"path/filepath"
)
func ExpandEnv(s string) string {
return os.ExpandEnv(s)
}
func LineSeparator() string {
return "\n"
}
func GetToolLocation(file string) string {
toolPath := NewEnvFlag(UnixToolLocation).GetValue(getExecutableDir)
4 years ago
return filepath.Join(toolPath, file)
}
// GetAssetLocation searches for `file` in certain locations
4 years ago
func GetAssetLocation(file string) string {
assetPath := NewEnvFlag(UnixAssetLocation).GetValue(getExecutableDir)
4 years ago
defPath := filepath.Join(assetPath, file)
for _, p := range []string{
defPath,
filepath.Join("/usr/local/share/xray/", file),
filepath.Join("/usr/share/xray/", file),
filepath.Join("/opt/share/xray/", file),
4 years ago
} {
if _, err := os.Stat(p); os.IsNotExist(err) {
continue
}
// asset found
return p
}
// asset not found, let the caller throw out the error
return defPath
}