// WriteTo is similar to GetFilename described just above in terms of
// locking discipline.
976886
func (k *SKBKeyringFile) WriteTo(w io.Writer) (n int64, err error) {
	k.G().Log.Debug("+ SKBKeyringFile WriteTo")
	defer k.G().Log.Debug("- SKBKeyringFile WriteTo")
	b64 := base64.NewEncoder(base64.StdEncoding, w)
	defer func() {
		// explicitly check for error on Close:
		if closeErr := b64.Close(); closeErr != nil {
			k.G().Log.Warning("SKBKeyringFile: WriteTo b64.Close() error: %s", closeErr)
			if err == nil {
				n = 0
				err = closeErr
				return
			}
		}
		k.G().Log.Debug("SKBKeyringFile: b64 stream closed successfully")
	}()

	if err := encodeSKBPacketList(k.Blocks, b64); err != nil {
		k.G().Log.Warning("Encoding problem: %s", err)
		return 0, err
	}

	return 0, nil
}
1047229
func (rb *Bitmap) WriteTo(stream io.Writer) (int64, error) {
	return rb.highlowcontainer.writeTo(stream)
}
1199389
func (c *Compound) WriteTo(w io.Writer) (n int64, err error) {
	var nn int64

	for name, tag := range c.Value {
		nn, err = tag.Type().WriteTo(w)
		if err != nil {
			return
		}
		n += nn

		nameTag := &String{name}
		nn, err = nameTag.WriteTo(w)
		if err != nil {
			return
		}
		n += nn

		nn, err = tag.WriteTo(w)
		if err != nil {
			return
		}
		n += nn
	}

	nn, err = TagEnd.New().WriteTo(w)
	if err != nil {
		return
	}
	n += nn

	return
}
1281027
func (c Config) WriteTo(w io.Writer) (int64, error) {
	data, err := json.Marshal(c)
	if err != nil {
		return int64(len(data)), err
	}
	return io.Copy(w, bytes.NewReader(data))
}
1097085
func (f File) WriteTo(w io.Writer) (int64, error) {
	n, err := w.Write(f.data)
	if err == nil {
		if n != len(f.data) {
			// this shouldn't happen
			//
			//    Write must return a non-nil error if it returns n < len(p)
			//
			// but check just in case
			return int64(n), io.ErrShortWrite
		}
	}
	return int64(n), err
}
815559
func (p *FSPath) WriteTo(out io.Writer) (int64, error) {
	f, err := os.Open(p.location)
	if err != nil {
		return 0, err
	}
	defer try.CloseFile(f)

	return io.Copy(out, f)
}
1093088
func (q *QueueStats) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, *q)
}
785910
func (m *Image) WriteTo(w io.Writer) (int64, error) {
	n, err := w.Write(m.encodedPNG())
	return int64(n), err
}
339806
func (b *Buffer) WriteTo(w io.Writer) (int64, error) {
	version := b.preOp()
	n, err := b.buf.WriteTo(w)
	b.postOp(version)
	return n, err
}
644257
func writeToFile(outputDir string, name string, data string) error {
	outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator))

	err := ensureDirectoryForFile(outfileName)
	if err != nil {
		return err
	}

	f, err := os.Create(outfileName)
	if err != nil {
		return err
	}

	defer f.Close()

	_, err = f.WriteString(fmt.Sprintf("---\n# Source: %s\n%s", name, data))

	if err != nil {
		return err
	}

	fmt.Printf("wrote %s\n", outfileName)
	return nil
}
1315432
func (p *Port) WriteTo(w io.Writer) (int64, error) {
	name := make([]byte, portNameLen)
	copy(name, []byte(p.Name))

	return encoding.WriteTo(w, p.PortNo, pad4{}, p.HWAddr, pad2{},
		name, p.Config, p.State, p.Curr, p.Advertised, p.Supported,
		p.Peer, p.CurrSpeed, p.MaxSpeed,
	)
}
933461
func (isNull IsNull) WriteTo(w Writer) error {
	_, err := fmt.Fprintf(w, "%s IS NULL", w.Key(isNull[0]))
	return err
}
473388
func (p *AssetPath) WriteTo(out io.Writer) (int64, error) {
	data, err := p.ReadFile()
	if err != nil {
		return 0, err
	}
	n, err := out.Write(data)
	return int64(n), err
}
249124
func (t *TablePropApplySetField) WriteTo(w io.Writer) (int64, error) {
	return writeTablePropXM(w, t, t.Fields)
}
1271831
func (c *Container) WriteTo(w io.Writer) (n int64, err error) {
	if c.isArray() {
		return c.arrayWriteTo(w)
	} else if c.isRun() {
		return c.runWriteTo(w)
	} else {
		return c.bitmapWriteTo(w)
	}
}
448086
func (header *Header) WriteTo(w io.Writer) (int64, error) {
	switch header.Version {
	case 1:
		return header.writeVersion1(w)
	case 2:
		return header.writeVersion2(w)
	default:
		return 0, ErrUnknownProxyProtocolVersion
	}
}
1296871
func (s *SeriesIDSet) WriteTo(w io.Writer) (int64, error) {
	s.RLock()
	defer s.RUnlock()
	return s.bitmap.WriteTo(w)
}