mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
get asset location
This commit is contained in:
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
Block a user