MCPcopy
hub / github.com/cli/cli / Copy

Method Copy

pkg/cmd/release/download/download.go:389–418  ·  view source on GitHub ↗

Copy writes the data from r into a file specified by name.

(name string, r io.Reader)

Source from the content-addressed store, hash-verified

387
388// Copy writes the data from r into a file specified by name.
389func (w destinationWriter) Copy(name string, r io.Reader) (copyErr error) {
390 fp := w.makePath(name)
391 if fp == "-" {
392 _, copyErr = io.Copy(w.stdout, r)
393 return
394 }
395 if copyErr = w.check(fp); copyErr != nil {
396 return
397 }
398
399 if dir := filepath.Dir(fp); dir != "." {
400 if copyErr = os.MkdirAll(dir, 0755); copyErr != nil {
401 return
402 }
403 }
404
405 var f *os.File
406 if f, copyErr = os.OpenFile(fp, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); copyErr != nil {
407 return
408 }
409
410 defer func() {
411 if err := f.Close(); copyErr == nil && err != nil {
412 copyErr = err
413 }
414 }()
415
416 _, copyErr = io.Copy(f, r)
417 return
418}
419
420func isWindowsReservedFilename(filename string) bool {
421 // Windows terminals should prevent the creation of these files

Callers 14

FetchRefSHAFunction · 0.45
fetchReleasePathFunction · 0.45
deleteReleaseFunction · 0.45
downloadAssetFunction · 0.45
cloneRunFunction · 0.45
forkRunFunction · 0.45
cloneWithRetryFunction · 0.45
localInitFunction · 0.45
deleteDeployKeyFunction · 0.45
uploadDeployKeyFunction · 0.45
setTopicsFunction · 0.45
CreateMethod · 0.45

Calls 3

makePathMethod · 0.95
checkMethod · 0.95
CloseMethod · 0.65

Tested by

no test coverage detected