MCPcopy
hub / github.com/google/codesearch / bufCreate

Function bufCreate

index/write.go:463–481  ·  view source on GitHub ↗

bufCreate creates a new file with the given name and returns a corresponding bufWriter. If name is empty, bufCreate uses a temporary file.

(name string)

Source from the content-addressed store, hash-verified

461// corresponding bufWriter. If name is empty, bufCreate uses a
462// temporary file.
463func bufCreate(name string) *bufWriter {
464 var (
465 f *os.File
466 err error
467 )
468 if name != "" {
469 f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
470 } else {
471 f, err = ioutil.TempFile("", "csearch")
472 }
473 if err != nil {
474 log.Fatal(err)
475 }
476 return &bufWriter{
477 name: f.Name(),
478 buf: make([]byte, 0, 256<<10),
479 file: f,
480 }
481}
482
483func (b *bufWriter) write(x []byte) {
484 n := cap(b.buf) - len(b.buf)

Callers 3

MergeFunction · 0.85
initMethod · 0.85
CreateFunction · 0.85

Calls 1

NameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…