MCPcopy
hub / github.com/dgraph-io/dgraph / WriteFileSync

Function WriteFileSync

x/file.go:20–32  ·  view source on GitHub ↗

WriteFileSync is the same as bufio.WriteFile, but syncs the data before closing.

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

Source from the content-addressed store, hash-verified

18
19// WriteFileSync is the same as bufio.WriteFile, but syncs the data before closing.
20func WriteFileSync(filename string, data []byte, perm os.FileMode) error {
21 f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
22 if err != nil {
23 return err
24 }
25 if _, err := f.Write(data); err != nil {
26 return err
27 }
28 if err := f.Sync(); err != nil {
29 return err
30 }
31 return f.Close()
32}
33
34// WalkPathFunc walks the directory 'dir' and collects all path names matched by
35// func f. If the path is a directory, it will set the bool argument to true.

Callers

nothing calls this directly

Calls 4

OpenFileMethod · 0.65
WriteMethod · 0.65
SyncMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected