// WriteToDisk writes content to disk.
511582
func WriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error) {
	return afero.WriteReader(fs, inpath, r)
}
796873
func (g *GroupMod) WriteTo(w io.Writer) (int64, error) {
	n, err := encoding.WriteTo(w, g.Command, g.Type, pad1{}, g.Group)
	if err != nil {
		return n, err
	}

	nn, err := encoding.WriteSliceTo(w, g.Buckets)
	return n + nn, err
}
19582
func (m *Image) WriteTo(w io.Writer) (int64, error) {
	return 0, png.Encode(w, m.Paletted)
}
1247397
func SafeWriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error) {
	return afero.SafeWriteReader(fs, inpath, r)
}
1050882
func (m *MultipartRequest) WriteTo(w io.Writer) (int64, error) {
	// By default, body will be embedded into the reader type.
	return encoding.WriteTo(w, m.Type, m.Flags, pad4{}, m.Body)
}
1348030
func (dh DirectoryHierarchy) WriteTo(w io.Writer) (n int64, err error) {
	sort.Sort(byPos(dh.Entries))
	var sum int64
	for _, e := range dh.Entries {
		str := e.String()
		i, err := io.WriteString(w, str+"\n")
		if err != nil {
			return sum, err
		}
		sum += int64(i)
	}
	return sum, nil
}
493312
func (u UnkDic) WriteTo(w io.Writer) (n int64, err error) {
	size, err := writeMap(w, u.UnkIndex)
	if err != nil {
		return n, err
	}
	n += size
	size, err = writeMap(w, u.UnkIndexDup)
	if err != nil {
		return n, err
	}
	n += size

	var buf bytes.Buffer
	enc := gob.NewEncoder(&buf)
	if err := enc.Encode(u.UnkMorphs); err != nil {
		return n, err
	}
	size, err = buf.WriteTo(w)
	if err != nil {
		return n, err
	}
	n += size
	if err := enc.Encode(u.UnkContents); err != nil {
		return n, err
	}
	size, err = buf.WriteTo(w)
	if err != nil {
		return n, err
	}
	n += size

	return n, nil
}
860555
func (i RawVInt) WriteTo(w Writer) error {
	var arr [8]byte
	n := 0
	for i != 0 {
		arr[n] = byte(i & 0xff)
		n++
		i >>= 8
	}
	_, err := w.Write(arr[:n])
	return errorsp.WithStacks(err)
}
651938
func (f *fragment) WriteTo(w io.Writer) (n int64, err error) {
	// Force cache flush.
	if err := f.FlushCache(); err != nil {
		return 0, errors.Wrap(err, "flushing cache")
	}

	// Write out data and cache to a tar archive.
	tw := tar.NewWriter(w)
	if err := f.writeStorageToArchive(tw); err != nil {
		return 0, fmt.Errorf("write storage: %s", err)
	}
	if err := f.writeCacheToArchive(tw); err != nil {
		return 0, fmt.Errorf("write cache: %s", err)
	}
	return 0, nil
}
706483
func (b *FileBookmarks) writeToFile() (err error) {
	j, err := json.Marshal(b.bookmarks)
	if err != nil {
		return err
	}
	fout, err := os.Create(b.file)
	if err != nil {
		return err
	}
	defer func() {
		err = fout.Close()
	}()
	_, err = fout.Write(j)
	if err != nil {
		return err
	}

	return err
}
1093088
func (q *QueueStats) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, *q)
}
423038
func (dbi *dbItem) writeDeleteTo(buf []byte) []byte {
	buf = appendArray(buf, 2)
	buf = appendBulkString(buf, "del")
	buf = appendBulkString(buf, dbi.key)
	return buf
}
350792
func (s Slice) WriteTo(w io.Writer) (n int64, err error) {
	nWrite, err := w.Write(s)
	return int64(nWrite), err
}
665616
func (row Row) WriteTo(writer io.Writer) (err error) {
	encoded, err := encodeRow(row)
	if err != nil {
		return fmt.Errorf("WriteTo encoding error: %v", err)
	}
	return WriteMessage(writer, encoded)
}
1305082
func (out *RAMOutputStream) WriteToBytes(bytes []byte) error {
	err := out.Flush()
	if err != nil {
		return err
	}
	end := out.file.length
	pos := int64(0)
	buffer := 0
	bytesUpto := 0
	for pos < end {
		length := BUFFER_SIZE
		nextPos := pos + int64(length)
		if nextPos > end {
			length = int(end - pos)
		}
		copy(bytes[bytesUpto:], out.file.Buffer(buffer)[:length])
		buffer++
		bytesUpto += length
		pos = nextPos
	}
	return nil
}
1321204
func (t *TableMod) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, t.Table, pad3{}, t.Config)
}
342712
func (b *runContainer16) writeTo(stream io.Writer) (int, error) {
	buf := make([]byte, 2+4*len(b.iv))
	binary.LittleEndian.PutUint16(buf[0:], uint16(len(b.iv)))
	for i, v := range b.iv {
		binary.LittleEndian.PutUint16(buf[2+i*4:], v.start)
		binary.LittleEndian.PutUint16(buf[2+2+i*4:], v.length)
	}
	return stream.Write(buf)
}