MCPcopy Create free account
hub / github.com/google/pprof / newTempFile

Function newTempFile

internal/driver/tempfile.go:25–36  ·  view source on GitHub ↗

newTempFile returns a new output file in dir with the provided prefix and suffix.

(dir, prefix, suffix string)

Source from the content-addressed store, hash-verified

23
24// newTempFile returns a new output file in dir with the provided prefix and suffix.
25func newTempFile(dir, prefix, suffix string) (*os.File, error) {
26 for index := 1; index < 10000; index++ {
27 switch f, err := os.OpenFile(filepath.Join(dir, fmt.Sprintf("%s%03d%s", prefix, index, suffix)), os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666); {
28 case err == nil:
29 return f, nil
30 case !os.IsExist(err):
31 return nil, err
32 }
33 }
34 // Give up
35 return nil, fmt.Errorf("could not create file of the form %s%03d%s", prefix, 1, suffix)
36}
37
38var tempFiles []string
39var tempFilesMu = sync.Mutex{}

Callers 5

awayFromTTYFunction · 0.85
invokeVisualizerFunction · 0.85
TestNewTempFileFunction · 0.85
fetchProfilesFunction · 0.85
convertPerfDataFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestNewTempFileFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…