Add Write(w io.Writer) to packbuilder

This wraps (*packbuilder).ForEach(), making it possible to write the
pack easiliy to a tcp-connection, a HTTP-Body or the like.
This commit is contained in:
Axel Wagner 2013-05-16 14:02:22 +02:00
parent 140f362428
commit 1da989e28b
1 changed files with 11 additions and 0 deletions

View File

@ -74,6 +74,17 @@ func (pb *Packbuilder) WriteToFile(name string) error {
return nil return nil
} }
func (pb *Packbuilder) Write(w io.Writer) error {
ch := pb.Foreach()
for _, slice := range ch {
_, err := w.Write(slice)
if err != nil {
return err
}
}
return nil
}
func (pb *Packbuilder) Written() uint32 { func (pb *Packbuilder) Written() uint32 {
return uint32(C.git_packbuilder_written(pb.ptr)) return uint32(C.git_packbuilder_written(pb.ptr))
} }