windows.go 834 B

12345678910111213141516171819202122232425262728293031
  1. // +build windows
  2. package platform
  3. import "path/filepath"
  4. func ExpandEnv(s string) string {
  5. // TODO
  6. return s
  7. }
  8. func LineSeparator() string {
  9. return "\r\n"
  10. }
  11. func GetToolLocation(file string) string {
  12. const name = "v2ray.location.tool"
  13. toolPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir)
  14. return filepath.Join(toolPath, file+".exe")
  15. }
  16. // GetAssetLocation search for `file` in the executable dir
  17. func GetAssetLocation(file string) string {
  18. filepathCleaned := filepath.Clean(file)
  19. if strings.HasPrefix("..", filepathCleaned) {
  20. newError("directory transversal is not allowed for assets. This will be forbidden in v5.").AtWarning().WriteToLog()
  21. }
  22. const name = "v2ray.location.asset"
  23. assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
  24. return filepath.Join(assetPath, file)
  25. }