Fix binaries having an identity crisis.

master
Icedream 2017-02-22 14:08:14 +01:00
parent 1b09d7e7f2
commit c3d53d04e1
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
2 changed files with 18 additions and 18 deletions

View File

@ -4,16 +4,16 @@ import (
"log" "log"
"os" "os"
"github.com/icedream/go-bsdiff/patch" "github.com/icedream/go-bsdiff/diff"
"gopkg.in/alecthomas/kingpin.v2" "gopkg.in/alecthomas/kingpin.v2"
) )
var ( var (
cli = kingpin.New("go-bspatch", "Applies binary patches generated using the bsdiff algorithm.") cli = kingpin.New("go-bsdiff", "Generates binary patches.")
argOld = cli.Arg("old", "The old file.").Required().ExistingFile() argOld = cli.Arg("old", "The old file.").Required().ExistingFile()
argNew = cli.Arg("new", "Where the new file will be written to.").Required().File() argNew = cli.Arg("new", "The new file.").Required().ExistingFile()
argPatch = cli.Arg("patch", "The patch file.").Required().ExistingFile() argPatch = cli.Arg("patch", "Where to output the patch file.").Required().File()
) )
func must(err error) { func must(err error) {
@ -27,16 +27,16 @@ func must(err error) {
func main() { func main() {
kingpin.MustParse(cli.Parse(os.Args[1:])) kingpin.MustParse(cli.Parse(os.Args[1:]))
newFile := *argNew patchFile := *argPatch
defer newFile.Close() defer patchFile.Close()
oldFile, err := os.Open(*argOld) oldFile, err := os.Open(*argOld)
must(err) must(err)
defer oldFile.Close() defer oldFile.Close()
patchFile, err := os.Open(*argPatch) newFile, err := os.Open(*argNew)
must(err) must(err)
defer patchFile.Close() defer newFile.Close()
must(patch.Patch(oldFile, newFile, patchFile)) must(diff.Diff(oldFile, newFile, patchFile))
} }

View File

@ -4,16 +4,16 @@ import (
"log" "log"
"os" "os"
"github.com/icedream/go-bsdiff/diff" "github.com/icedream/go-bsdiff/patch"
"gopkg.in/alecthomas/kingpin.v2" "gopkg.in/alecthomas/kingpin.v2"
) )
var ( var (
cli = kingpin.New("go-bsdiff", "Generates binary patches.") cli = kingpin.New("go-bspatch", "Applies binary patches generated using the bsdiff algorithm.")
argOld = cli.Arg("old", "The old file.").Required().ExistingFile() argOld = cli.Arg("old", "The old file.").Required().ExistingFile()
argNew = cli.Arg("new", "The new file.").Required().ExistingFile() argNew = cli.Arg("new", "Where the new file will be written to.").Required().File()
argPatch = cli.Arg("patch", "Where to output the patch file.").Required().File() argPatch = cli.Arg("patch", "The patch file.").Required().ExistingFile()
) )
func must(err error) { func must(err error) {
@ -27,16 +27,16 @@ func must(err error) {
func main() { func main() {
kingpin.MustParse(cli.Parse(os.Args[1:])) kingpin.MustParse(cli.Parse(os.Args[1:]))
patchFile := *argPatch newFile := *argNew
defer patchFile.Close() defer newFile.Close()
oldFile, err := os.Open(*argOld) oldFile, err := os.Open(*argOld)
must(err) must(err)
defer oldFile.Close() defer oldFile.Close()
newFile, err := os.Open(*argNew) patchFile, err := os.Open(*argPatch)
must(err) must(err)
defer newFile.Close() defer patchFile.Close()
must(diff.Diff(oldFile, newFile, patchFile)) must(patch.Patch(oldFile, newFile, patchFile))
} }