// Write writes the fp.generated.go file for a package.
540432
func (b *Binding) Write(dst io.Writer) error {
	hdr := "// GENERATED BY GOFAIL. DO NOT EDIT.\n\n" +
		"package " + b.pkg +
		"\n\nimport \"github.com/etcd-io/gofail/runtime\"\n\n"
	if _, err := fmt.Fprint(dst, hdr); err != nil {
		return err
	}
	for _, fp := range b.fps {
		_, err := fmt.Fprintf(
			dst,
			"var %s *runtime.Failpoint = runtime.NewFailpoint(%q, %q)\n",
			fp.Runtime(),
			b.fppath,
			fp.Name())
		if err != nil {
			return err
		}
	}
	return nil
}
30601
func (g *Generator) Write(output string) {
	if err := ioutil.WriteFile(output, g.buf.Bytes(), 0644); err != nil {
		log.Fatalln(err)
	}
}
25609
func (fw *flushWriter) Write(p []byte) (n int, err error) {
	n, err = fw.writer.Write(p)
	if err != nil {
		return
	}
	if fw.flusher != nil {
		fw.flusher.Flush()
	}
	return
}
155913
func (f *File) Write(b []byte) (int, error) {
	if !f.writing {
		f.writing = true

		go func() {
			_, err := f.c.Files.Upload(&dropbox.UploadInput{
				Mode:   dropbox.WriteModeOverwrite,
				Path:   f.Name,
				Mute:   true,
				Reader: f.pipeR,
			})

			f.pipeR.CloseWithError(err)
		}()
	}

	return f.pipeW.Write(b)
}
963112
func (b *ByteBuffer) Write(p []byte) (int, error) {
	b.B = append(b.B, p...)
	return len(p), nil
}
280040
func (w *FuncWriter) Write(b []byte) (int, error) {
	w.fx(b)
	return len(b), nil
}
644182
func (rc *rawConn) Write(fn func(fd uintptr) (done bool)) error {
	return rc.opError(opRawWrite, rc.rc.Write(fn))
}
233956
func (w *Writer) Write(p []byte) (n int, err error) {
	return w.buf.Write(p)
}
457274
func write(prog *cc.Prog, filenames []string, cfg *Config) {
	files := map[string]*outFile{}
	havePkg := map[string]bool{}
	for _, decl := range prog.Decls {
		if decl.GoPackage == "" {
			pkg := findPkg(cfg, decl.Span.Start.File)
			if pkg == "" {
				continue
			}
			decl.GoPackage = pkg
		}
		file := decl.Span.Start.File
		file = strings.TrimSuffix(strings.TrimSuffix(file, ".c"), ".h") + ".go"
		file = filepath.Base(file)
		pkg := decl.GoPackage
		file = pkg + "/" + file
		f := files[file]
		if f == nil {
			f = new(outFile)
			f.p.Package = pkg
			files[file] = f
			f.p.Print("package ", path.Base(pkg), "\n\n")
			if !havePkg[pkg] {
				havePkg[pkg] = true
				f.p.Print(bool2int)
			}
		}

		if cfg.Delete[decl.Name] {
			f.p.Print(decl.Comments.Before)
			f.p.Print(decl.Comments.Suffix, decl.Comments.After)
			continue
		}
		off := len(f.p.Bytes())
		repl, ok := cfg.Replace[decl.Name]
		if !ok {
			repl, ok = cfg.Replace[strings.ToLower(decl.Name)]
		}
		if ok {
			f.p.Print(decl.Comments.Before)
			f.p.Print(repl)
			f.p.Print(decl.Comments.Suffix, decl.Comments.After)
		} else {
			f.p.Print(decl)
		}
		if len(f.p.Bytes()) > off {
			f.p.Print(c2go.Newline)
			f.p.Print(c2go.Newline)
		}
	}

	for pkgfile, f := range files {
		dstfile := filepath.Join(*out, pkgfile)
		buf := f.p.Bytes()
		buf1, err := format.Source(f.p.Bytes())
		if err == nil {
			buf = buf1
		}
		out := string(buf)
		for i, d := range cfg.Diffs {
			if strings.Contains(out, d.Before) {
				out = strings.Replace(out, d.Before, d.After, -1)
				cfg.Diffs[i].Used++
			}
		}
		if err := os.MkdirAll(filepath.Dir(dstfile), 0777); err != nil {
			log.Print(err)
		}
		if err := ioutil.WriteFile(dstfile, []byte(out), 0666); err != nil {
			log.Print(err)
		}
	}
}
147063
func (u *Ugen) Write(w io.Writer) error {
	// write the synthdef name
	if err := newPstring(u.Name).Write(w); err != nil {
		return err
	}
	// write rate
	if err := binary.Write(w, byteOrder, u.Rate); err != nil {
		return err
	}
	// write inputs
	numInputs := int32(len(u.Inputs))
	if err := binary.Write(w, byteOrder, numInputs); err != nil {
		return err
	}
	// write outputs
	numOutputs := int32(len(u.Outputs))
	if err := binary.Write(w, byteOrder, numOutputs); err != nil {
		return err
	}
	// special index
	if err := binary.Write(w, byteOrder, u.SpecialIndex); err != nil {
		return err
	}
	// inputs
	for _, i := range u.Inputs {
		if err := i.Write(w); err != nil {
			return err
		}
	}
	// outputs
	for _, o := range u.Outputs {
		if err := o.Write(w); err != nil {
			return err
		}
	}
	return nil
}
391071
func (w *BackupFileWriter) Write(b []byte) (int, error) {
	var bytesWritten uint32
	err := backupWrite(syscall.Handle(w.f.Fd()), b, &bytesWritten, false, w.includeSecurity, &w.ctx)
	if err != nil {
		return 0, &os.PathError{"BackupWrite", w.f.Name(), err}
	}
	runtime.KeepAlive(w.f)
	if int(bytesWritten) != len(b) {
		return int(bytesWritten), errors.New("not all bytes could be written")
	}
	return len(b), nil
}
407254
func Write(w io.Writer, bundle Bundle) error {
	gw := gzip.NewWriter(w)
	tw := tar.NewWriter(gw)

	var buf bytes.Buffer

	if err := json.NewEncoder(&buf).Encode(bundle.Data); err != nil {
		return err
	}

	if err := writeFile(tw, "data.json", buf.Bytes()); err != nil {
		return err
	}

	for _, module := range bundle.Modules {
		if err := writeFile(tw, module.Path, module.Raw); err != nil {
			return err
		}
	}

	if err := writeManifest(tw, bundle); err != nil {
		return err
	}

	if err := tw.Close(); err != nil {
		return err
	}

	return gw.Close()
}
666238
func (s *BytesWriter) Write(buf []byte) (int, error) {
	return s.writer.Write(buf)
}
250914
func (b *PackBuffer) Write(p []byte) (n int, err error) {

	space := b.WriteLen()
	if space < len(p) {
		n = copy(b.s[b.w:], p)
		b.w = b.w + n
	} else {
		b.Compact(false)
		space = b.WriteLen()
		if space > len(p) {
			n = copy(b.s[b.w:], p[:])
		} else {
			n = copy(b.s[b.w:], p[:space])
		}
	}
	if n == 0 {
		return 0, errors.New("No room left in buffer")
	}
	return n, nil
}
1121039
func (w *Writer) Write(buf []byte) (int, error) {
	return w.Writer.Write(buf)
}
397136
func (b *Builder) Write(p []byte) (n int, err error) {
	b.lastRead = opInvalid
	m := b.grow(len(p))
	return copy(b.buf[m:], p), nil
}
315148
func (w *Writer) Write(buf []byte) (n int, err error) {
	w.mtx.Lock()
	defer w.mtx.Unlock()
	return w.buf.Write(buf)
}