MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / CopyConfigTemplate

Function CopyConfigTemplate

internal/misc/copy-example-config.go:11–40  ·  view source on GitHub ↗
(src, dst string)

Source from the content-addressed store, hash-verified

9)
10
11func CopyConfigTemplate(src, dst string) error {
12 in, err := os.Open(src)
13 if err != nil {
14 return err
15 }
16 defer func() {
17 if errClose := in.Close(); errClose != nil {
18 log.WithError(errClose).Warn("failed to close source config file")
19 }
20 }()
21
22 if err = os.MkdirAll(filepath.Dir(dst), 0o700); err != nil {
23 return err
24 }
25
26 out, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o600)
27 if err != nil {
28 return err
29 }
30 defer func() {
31 if errClose := out.Close(); errClose != nil {
32 log.WithError(errClose).Warn("failed to close destination config file")
33 }
34 }()
35
36 if _, err = io.Copy(out, in); err != nil {
37 return err
38 }
39 return out.Sync()
40}

Callers 3

syncConfigFromBucketMethod · 0.92
mainFunction · 0.92

Calls 2

OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected