mirror of https://github.com/v2ray/v2ray-core
get asset location
parent
cec45a416c
commit
1d2c624062
|
@ -2,6 +2,7 @@ package platform
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
@ -40,3 +41,19 @@ func (f EnvFlag) GetValueAsInt(defaultValue int) int {
|
|||
func NormalizeEnvName(name string) string {
|
||||
return strings.Replace(strings.ToUpper(strings.TrimSpace(name)), ".", "_", -1)
|
||||
}
|
||||
|
||||
var assetPath = "/"
|
||||
|
||||
func init() {
|
||||
defAssetLocation, err := os.Executable()
|
||||
if err == nil {
|
||||
defAssetLocation = filepath.Dir(defAssetLocation)
|
||||
assetPath = (EnvFlag{
|
||||
Name: "v2ray.location.asset",
|
||||
}).GetValue(defAssetLocation)
|
||||
}
|
||||
}
|
||||
|
||||
func GetAssetLocation(file string) string {
|
||||
return filepath.Join(assetPath, file)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue