MCPcopy Create free account
hub / github.com/containerd/nerdctl / internalCopy

Function internalCopy

pkg/internal/filesystem/helpers.go:189–209  ·  view source on GitHub ↗

internalCopy performs a simple copy from source to destination. This in itself is not safe.

(sourcePath, destinationPath string)

Source from the content-addressed store, hash-verified

187// internalCopy performs a simple copy from source to destination.
188// This in itself is not safe.
189func internalCopy(sourcePath, destinationPath string) (err error) {
190 var source *os.File
191
192 // Open source
193 source, err = os.OpenFile(sourcePath, os.O_RDONLY, privateFilePermission)
194 if err != nil {
195 return err
196 }
197
198 defer func() {
199 err = errors.Join(err, source.Close())
200 }()
201
202 // Read file length
203 srcInfo, err := source.Stat()
204 if err != nil {
205 return err
206 }
207
208 return fileWrite(source, srcInfo.Size(), destinationPath, privateFilePermission, srcInfo.ModTime())
209}
210
211// fileWrite performs a simple write to the destination file from the provided io.Reader.
212// This in itself is not safe.

Callers 2

backupSaveFunction · 0.85
backupRestoreFunction · 0.85

Calls 4

fileWriteFunction · 0.85
StatMethod · 0.80
SizeMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…