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

Function WriteFileWithRename

pkg/internal/filesystem/writefile_rename.go:42–44  ·  view source on GitHub ↗

WriteFileWithRename is a drop-in replacement for os.WriteFile, with the same signature and almost identical behavior (see note below on inodes). Unlike os.WriteFile, it does provide extra guarantees: - Atomicity (provided by rename - *mostly* atomic, except on OS crash, where rename behavior is unde

(filename string, data []byte, perm os.FileMode)

Source from the content-addressed store, hash-verified

40// Finally note that we do not do anything smart wrt symlinks.
41// User is expected to resolve symlink for the destination before calling this if needed.
42func WriteFileWithRename(filename string, data []byte, perm os.FileMode) error {
43 return CopyToFileWithRename(filename, bytes.NewBuffer(data), int64(len(data)), perm, time.Time{})
44}
45
46// CopyToFileWithRename is an atomic wrapper around io.Copy(file, reader). See notes above in WriteFile for details.
47func CopyToFileWithRename(filename string, reader io.Reader, dataSize int64, perm os.FileMode, mTime time.Time) (err error) {

Callers 1

SetMethod · 0.92

Calls 1

CopyToFileWithRenameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…