others.go 541 B

123456789101112131415161718192021222324252627
  1. //go:build !windows
  2. // +build !windows
  3. package platform
  4. import (
  5. "path/filepath"
  6. "github.com/adrg/xdg"
  7. )
  8. func LineSeparator() string {
  9. return "\n"
  10. }
  11. // GetAssetLocation search for `file` in certain locations
  12. func GetAssetLocation(file string) string {
  13. const name = "v2ray.location.asset"
  14. assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
  15. defPath := filepath.Join(assetPath, file)
  16. relPath := filepath.Join("v2ray", file)
  17. fullPath, err := xdg.SearchDataFile(relPath)
  18. if err != nil {
  19. return defPath
  20. }
  21. return fullPath
  22. }