1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

get asset location

This commit is contained in:
Darien Raymond 2017-11-04 21:33:09 +01:00
parent cec45a416c
commit 1d2c624062

View File

@ -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)
}