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

Function safeCreate

dgraph/cmd/cert/create.go:134–140  ·  view source on GitHub ↗

safeCreate only creates a file if it doesn't exist or we force overwrite.

(name string, overwrite bool, perm os.FileMode)

Source from the content-addressed store, hash-verified

132
133// safeCreate only creates a file if it doesn't exist or we force overwrite.
134func safeCreate(name string, overwrite bool, perm os.FileMode) (*os.File, error) {
135 flag := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
136 if !overwrite {
137 flag |= os.O_EXCL
138 }
139 return os.OpenFile(name, flag, perm)
140}
141
142// createCAPair creates a CA certificate and key pair. The key file is created only
143// if it doesn't already exist or we force it. The key path can differ from the certsDir

Callers 2

makeKeyFunction · 0.85
generatePairMethod · 0.85

Calls 1

OpenFileMethod · 0.65

Tested by

no test coverage detected