MCPcopy
hub / github.com/git-lfs/git-lfs / CopyFileContents

Function CopyFileContents

lfs/util.go:192–215  ·  view source on GitHub ↗
(cfg *config.Configuration, src string, dst string)

Source from the content-addressed store, hash-verified

190}
191
192func CopyFileContents(cfg *config.Configuration, src string, dst string) error {
193 tmp, err := TempFile(cfg, filepath.Base(dst))
194 if err != nil {
195 return err
196 }
197 defer func() {
198 tmp.Close()
199 os.Remove(tmp.Name())
200 }()
201 in, err := os.Open(src)
202 if err != nil {
203 return err
204 }
205 defer in.Close()
206 _, err = io.Copy(tmp, in)
207 if err != nil {
208 return err
209 }
210 err = tmp.Close()
211 if err != nil {
212 return err
213 }
214 return os.Rename(tmp.Name(), dst)
215}
216
217func LinkOrCopy(cfg *config.Configuration, src string, dst string) error {
218 if src == dst {

Callers 2

mergeProcessInputFunction · 0.92
LinkOrCopyFunction · 0.85

Calls 4

TempFileFunction · 0.70
CloseMethod · 0.65
NameMethod · 0.65
RemoveMethod · 0.45

Tested by

no test coverage detected