MCPcopy Create free account
hub / github.com/dim-an/cod / CopyFile

Method CopyFile

test/lib.go:97–119  ·  view source on GitHub ↗
(src, dst string)

Source from the content-addressed store, hash-verified

95}
96
97func (wb *Workbench) CopyFile(src, dst string) {
98 fileInfo, err := os.Stat(src)
99 require.Nil(wb.t, err)
100
101 in, err := os.Open(src)
102 require.Nil(wb.t, err)
103 defer func() {
104 _ = in.Close()
105 }()
106
107 out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fileInfo.Mode())
108 require.Nil(wb.t, err)
109 defer func() {
110 err := out.Close()
111 require.Nil(wb.t, err)
112 }()
113
114 _, err = io.Copy(out, in)
115 require.Nil(wb.t, err)
116
117 err = out.Sync()
118 require.Nil(wb.t, err)
119}
120
121func (wb *Workbench) InTmpDataPath(path string) string {
122 return filepath.Join(wb.currentTestTmpDir, path)

Callers 5

TestUpdateReplaceFunction · 0.80
TestUpdateMergeFunction · 0.80
TestUpdateBrokenFunction · 0.80
TestLearnFromPATHFunction · 0.80
TestMergeLearnFunction · 0.80

Calls 1

CloseMethod · 0.65

Tested by 5

TestUpdateReplaceFunction · 0.64
TestUpdateMergeFunction · 0.64
TestUpdateBrokenFunction · 0.64
TestLearnFromPATHFunction · 0.64
TestMergeLearnFunction · 0.64