writer

package
v0.0.0-...-10c22ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryWriter

type BinaryWriter struct {
	Size int64
	// contains filtered or unexported fields
}

BinaryWriter is the writer which can be used to write values of primitive types to a writer The writer supports writing data both in little-endian or big-endian format.

func NewBinaryWriter

func NewBinaryWriter(to io.WriterAt, order binary.ByteOrder, size int64) *BinaryWriter

NewBinaryWriter creates a new instance of BinaryWriter, to is the underlying data source to write to, order is the byte order used to encode the data in the source, size is the length of the data source in bytes.

func (*BinaryWriter) WriteBoolean

func (w *BinaryWriter) WriteBoolean(off int64, value bool)

WriteBoolean write a boolean value to the underlying writer at offset off.

func (*BinaryWriter) WriteByte

func (w *BinaryWriter) WriteByte(off int64, value byte)

WriteByte write a byte value to the underlying writer at offset off.

func (*BinaryWriter) WriteBytes

func (w *BinaryWriter) WriteBytes(off int64, value []byte)

WriteBytes writes a byte slice to the underlying writer at offset off.

func (*BinaryWriter) WriteInt16

func (w *BinaryWriter) WriteInt16(off int64, value int16)

WriteInt16 encodes an int16 and write it in the underlying writer at offset off.

func (*BinaryWriter) WriteInt32

func (w *BinaryWriter) WriteInt32(off int64, value int32)

WriteInt32 encodes an int32 and write it in the underlying writer at offset off.

func (*BinaryWriter) WriteInt64

func (w *BinaryWriter) WriteInt64(off int64, value int64)

WriteInt64 encodes an int64 and write it in the underlying writer at offset off.

func (*BinaryWriter) WriteString

func (w *BinaryWriter) WriteString(off int64, value string)

WriteString writes a string to the underlying writer at offset off.

func (*BinaryWriter) WriteUInt16

func (w *BinaryWriter) WriteUInt16(off int64, value uint16)

WriteUInt16 encodes an uint16 and write it in the underlying writer at offset off.

func (*BinaryWriter) WriteUInt32

func (w *BinaryWriter) WriteUInt32(off int64, value uint32)

WriteUInt32 encodes an uint32 and write it in the underlying writer at offset off.

func (*BinaryWriter) WriteUInt64

func (w *BinaryWriter) WriteUInt64(off int64, value uint64)

WriteUInt64 encodes an uint64 and write it in the underlying writer at offset off.

type ByteSliceWriteAt

type ByteSliceWriteAt []byte

ByteSliceWriteAt is a type that satisfies io.WriteAt interface for byte slice.

func (ByteSliceWriteAt) WriteAt

func (s ByteSliceWriteAt) WriteAt(b []byte, off int64) (n int, err error)

WriteAt copies len(b) bytes to the byte slice starting at byte offset off. It returns the number of bytes copied and an error, if any. WriteAt returns a non-nil error when n != len(b).

type VhdWriter

type VhdWriter struct {
	*BinaryWriter
}

VhdWriter is the writer used by various components responsible for writing header and footer of the VHD.

func NewVhdWriter

func NewVhdWriter(target io.WriterAt, size int64) *VhdWriter

NewVhdWriter creates new instance of the VhdWriter, that writes to the underlying target, size is the size of the target in bytes.

func NewVhdWriterFromByteSlice

func NewVhdWriterFromByteSlice(b []byte) *VhdWriter

NewVhdWriterFromByteSlice creates a new instance of VhdWriter, that uses the given byte slice as the underlying target to write to.

func (*VhdWriter) WriteTimeStamp

func (r *VhdWriter) WriteTimeStamp(off int64, time *time.Time)

WriteTimeStamp writes vhd timestamp represented by the given time to underlying source starting at byte offset off.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL