1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 09:56:18 -05:00
v2fly/common/platform/others.go
Nick Cao 118a99e773
search for assets in xdg data directories on non-windows platforms (#1578)
* common/platform: cleanup unused functions

* common/platform: search for assets in xdg data directories on non-windows platforms
2022-02-06 14:24:23 +08:00

28 lines
541 B
Go

//go:build !windows
// +build !windows
package platform
import (
"path/filepath"
"github.com/adrg/xdg"
)
func LineSeparator() string {
return "\n"
}
// GetAssetLocation search for `file` in certain locations
func GetAssetLocation(file string) string {
const name = "v2ray.location.asset"
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
defPath := filepath.Join(assetPath, file)
relPath := filepath.Join("v2ray", file)
fullPath, err := xdg.SearchDataFile(relPath)
if err != nil {
return defPath
}
return fullPath
}