Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabstv committed Feb 25, 2019
1 parent 85f1716 commit 7dc9a3f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ import (
)

func main(){
// example files
oldfile := []byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff}
newfile := []byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0xff, 0xfe, 0xfe}

// generate a BSDIFF4 patch
patch, err := bsdiff.Bytes(oldfile, newfile)
if err != nil {
panic(err)
}
fmt.Println(patch)

// Apply a BSDIFF4 patch
newfile2, err := bspatch.Bytes(oldfile, patch)
if err != nil {
panic(err)
Expand All @@ -52,11 +57,16 @@ func main(){
oldrdr := bytes.NewReader([]byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff})
newrdr := bytes.NewReader([]byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0xff, 0xfe, 0xfe})
patch := new(bytes.Buffer)

// generate a BSDIFF4 patch
if err := bsdiff.Reader(oldrdr, newrdr, patch); err != nil {
panic(err)
}

newpatchedf := new(bytes.Buffer)
oldrdr.Seek(0, 0)

// Apply a BSDIFF4 patch
if err := bspatch.Reader(oldrdr, newpatchedf, patch); err != nil {
panic(err)
}
Expand Down

0 comments on commit 7dc9a3f

Please sign in to comment.