MCPcopy Index your code
hub / github.com/rclone/rclone / WriteFile

Method WriteFile

vfs/vfs.go:832–840  ·  view source on GitHub ↗

WriteFile writes data to the named file, creating it if necessary. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions. Since WriteFile requires multiple system calls to complete, a failu

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

Source from the content-addressed store, hash-verified

830// permissions. Since WriteFile requires multiple system calls to complete,
831// a failure mid-operation can leave the file in a partially written state.
832func (vfs *VFS) WriteFile(name string, data []byte, perm os.FileMode) (err error) {
833 fh, err := vfs.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
834 if err != nil {
835 return err
836 }
837 defer fs.CheckClose(fh, &err)
838 _, err = fh.Write(data)
839 return err
840}
841
842// AddVirtual adds the object (file or dir) to the directory cache
843//

Calls 3

OpenFileMethod · 0.95
CheckCloseFunction · 0.92
WriteMethod · 0.65