MCPcopy Index your code
hub / github.com/TruthHun/BookStack / CopyFile

Function CopyFile

utils/file.go:43–58  ·  view source on GitHub ↗
(dstName, srcName string)

Source from the content-addressed store, hash-verified

41}
42
43func CopyFile(dstName, srcName string) (written int64, err error) {
44 dstName = strings.TrimLeft(dstName, "./")
45 srcName = strings.TrimLeft(srcName, "./")
46 src, err := os.Open(srcName)
47 if err != nil {
48 return
49 }
50 defer src.Close()
51 dst, err := os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE, 0644)
52 if err != nil {
53 return
54 }
55
56 defer dst.Close()
57 return io.Copy(dst, src)
58}
59
60func FormatBytes(size int64) string {
61 units := []string{" B", " KB", " MB", " GB", " TB"}

Callers 2

ResolveCommandFunction · 0.92
CopyMethod · 0.92

Calls 1

CopyMethod · 0.45

Tested by

no test coverage detected