1
mirror of https://github.com/XTLS/Xray-core.git synced 2025-12-12 04:34:41 +04:00
Files
xray-core/common/platform/others.go
𐲓𐳛𐳪𐳂𐳐 𐲀𐳢𐳦𐳫𐳢 𐲥𐳔𐳛𐳪𐳌𐳑𐳖𐳇 aea123842b Chore: Remove ctlcmd and leftover envvar (#5392)
https://github.com/v2fly/v2ray-core/issues/360
2025-12-08 13:27:22 +00:00

42 lines
968 B
Go

//go:build !windows
// +build !windows
package platform
import (
"os"
"path/filepath"
)
func LineSeparator() string {
return "\n"
}
// GetAssetLocation searches for `file` in the env dir, the executable dir, and certain locations
func GetAssetLocation(file string) string {
assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir)
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),
} {
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
}
// GetCertLocation searches for `file` in the env dir and the executable dir
func GetCertLocation(file string) string {
certPath := NewEnvFlag(CertLocation).GetValue(getExecutableDir)
return filepath.Join(certPath, file)
}