2017-02-12 04:13:29 +00:00
|
|
|
package packer
|
|
|
|
|
|
|
|
import "bytes"
|
|
|
|
|
|
|
|
//packerData -- Contains packer data
|
|
|
|
type packerData struct {
|
2017-03-02 03:02:20 +00:00
|
|
|
buffer *bytes.Buffer
|
|
|
|
DataLen int
|
2017-02-12 04:13:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newPackerData() (p *packerData) {
|
|
|
|
p = new(packerData)
|
2017-02-14 00:47:16 +00:00
|
|
|
p.buffer = new(bytes.Buffer)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-03-03 00:47:59 +00:00
|
|
|
func (p *packerData) AppendString(dataString string) (n int, err error) {
|
2017-02-14 00:47:16 +00:00
|
|
|
n, err = p.buffer.WriteString(dataString)
|
2017-02-12 04:13:29 +00:00
|
|
|
return
|
|
|
|
}
|
2017-02-14 02:36:01 +00:00
|
|
|
|
2017-03-03 00:47:59 +00:00
|
|
|
func (p *packerData) AppendBytes(dataBytes []byte) (n int, err error) {
|
2017-02-14 02:36:01 +00:00
|
|
|
n, err = p.buffer.Write(dataBytes)
|
|
|
|
return
|
|
|
|
}
|
2017-03-03 00:47:59 +00:00
|
|
|
|
|
|
|
//Data --
|
|
|
|
func (p *packerData) Data() (b []byte) {
|
|
|
|
b = p.buffer.Bytes()
|
|
|
|
return
|
|
|
|
}
|