| 1 | // +build !windows |
| 2 | |
| 3 | package platformscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/ |
| 4 | |
| 5 | import ( |
| 6 | "osscip-go gomod github.com/golang/go/src go1.15 os/" |
| 7 | "path/filepathscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/" |
| 8 | ) |
| 9 | |
| 10 | func ExpandEnvscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/ExpandEnv().(s string) string { |
| 11 | return osscip-go gomod github.com/golang/go/src go1.15 os/.ExpandEnvscip-go gomod github.com/golang/go/src go1.15 os/ExpandEnv().(s) |
| 12 | } |
| 13 | |
| 14 | func LineSeparatorscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/LineSeparator().() string { |
| 15 | return "\n" |
| 16 | } |
| 17 | |
| 18 | func GetToolLocationscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/GetToolLocation().(file string) string { |
| 19 | const name = "v2ray.location.tool" |
| 20 | toolPath := EnvFlagscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#{Namescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#Name.: name, AltNamescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#AltName.: NormalizeEnvNamescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/NormalizeEnvName().(name)}.GetValuescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#GetValue().(getExecutableDirscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/getExecutableDir().) |
| 21 | return filepathscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/Join().(toolPath, file) |
| 22 | } |
| 23 | |
| 24 | // GetAssetLocation search for `file` in certain locations |
| 25 | func GetAssetLocationscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/GetAssetLocation().(file string) string { |
| 26 | const name = "v2ray.location.asset" |
| 27 | assetPath := NewEnvFlagscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/NewEnvFlag().(name).GetValuescip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/EnvFlag#GetValue().(getExecutableDirscip-go gomod v2ray.com/core . `v2ray.com/core/common/platform`/getExecutableDir().) |
| 28 | defPath := filepathscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/Join().(assetPath, file) |
| 29 | for _, p := range []string{ |
| 30 | defPath, |
| 31 | filepathscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/Join().("/usr/local/share/v2ray/", file), |
| 32 | filepathscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.15 `path/filepath`/Join().("/usr/share/v2ray/", file), |
| 33 | } { |
| 34 | if _, err := osscip-go gomod github.com/golang/go/src go1.15 os/.Statscip-go gomod github.com/golang/go/src go1.15 os/Stat().(p); osscip-go gomod github.com/golang/go/src go1.15 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.15 os/IsNotExist().(err) { |
| 35 | continue |
| 36 | } |
| 37 | |
| 38 | // asset found |
| 39 | return p |
| 40 | } |
| 41 | |
| 42 | // asset not found, let the caller throw out the error |
| 43 | return defPath |
| 44 | } |