MCPcopy Index your code
hub / github.com/pquerna/ffjson / TempFileWithPostfix

Function TempFileWithPostfix

generator/tempfile.go:47–65  ·  view source on GitHub ↗

TempFile creates a new temporary file in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, TempFile uses the default directory for temporary files (see os.TempDir). Multiple programs calling Te

(dir, prefix string, postfix string)

Source from the content-addressed store, hash-verified

45// to find the pathname of the file. It is the caller's responsibility
46// to remove the file when no longer needed.
47func TempFileWithPostfix(dir, prefix string, postfix string) (f *os.File, err error) {
48 if dir == "" {
49 dir = os.TempDir()
50 }
51
52 nconflict := 0
53 for i := 0; i < 10000; i++ {
54 name := filepath.Join(dir, prefix+nextSuffix()+postfix)
55 f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
56 if os.IsExist(err) {
57 if nconflict++; nconflict > 10 {
58 rand = reseed()
59 }
60 continue
61 }
62 break
63 }
64 return
65}

Callers 1

GenerateMethod · 0.85

Calls 2

nextSuffixFunction · 0.85
reseedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…