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)
| 830 | // permissions. Since WriteFile requires multiple system calls to complete, |
| 831 | // a failure mid-operation can leave the file in a partially written state. |
| 832 | func (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 | // |