1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

Allow setting permission on CopyFile helper

This commit is contained in:
Shelikhoo 2024-03-11 20:57:55 +00:00 committed by Xiaokang Wang (Shelikhoo)
parent 887280e848
commit 353326b432
2 changed files with 3 additions and 3 deletions

View File

@ -45,12 +45,12 @@ func ReadAsset(file string) ([]byte, error) {
return ReadFile(platform.GetAssetLocation(file))
}
func CopyFile(dst string, src string) error {
func CopyFile(dst string, src string, perm os.FileMode) error {
bytes, err := ReadFile(src)
if err != nil {
return err
}
f, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, 0o644)
f, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, perm)
if err != nil {
return err
}

View File

@ -39,7 +39,7 @@ func init() {
func TestToCidrList(t *testing.T) {
t.Log(os.Getenv("v2ray.location.asset"))
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoiptestrouter.dat"), platform.GetAssetLocation("geoip.dat")))
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoiptestrouter.dat"), platform.GetAssetLocation("geoip.dat"), 0o600))
ips := cfgcommon.StringList([]string{
"geoip:us",