Create a signature for the data source in src.
(src io.Reader, output io.Writer)
| 193 | |
| 194 | // Create a signature for the data source in src. |
| 195 | func (self *Patcher) CreateSignatureIterator(src io.Reader, output io.Writer) func() error { |
| 196 | var it func() (BlockHash, error) |
| 197 | finished := false |
| 198 | var b [BlockHashSize]byte |
| 199 | return func() error { |
| 200 | if finished { |
| 201 | return io.EOF |
| 202 | } |
| 203 | if it == nil { // write signature header |
| 204 | it = self.rsync.CreateSignatureIterator(src) |
| 205 | bin.PutUint16(b[:], 0) |
| 206 | bin.PutUint16(b[2:], uint16(self.Checksum_type)) |
| 207 | bin.PutUint16(b[4:], uint16(self.Strong_hash_type)) |
| 208 | bin.PutUint16(b[6:], uint16(self.Weak_hash_type)) |
| 209 | bin.PutUint32(b[8:], uint32(self.rsync.BlockSize)) |
| 210 | if _, err := output.Write(b[:12]); err != nil { |
| 211 | return err |
| 212 | } |
| 213 | } |
| 214 | bl, err := it() |
| 215 | switch err { |
| 216 | case io.EOF: |
| 217 | finished = true |
| 218 | return io.EOF |
| 219 | case nil: |
| 220 | bl.Serialize(b[:BlockHashSize]) |
| 221 | _, err = output.Write(b[:BlockHashSize]) |
| 222 | return err |
| 223 | default: |
| 224 | return err |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | // Create a serialized delta based on the previously loaded signature |
| 230 | func (self *Differ) CreateDelta(src io.Reader, output io.Writer) func() error { |