From 297d5a52a9f84be3e3be8817673d44449aa42113 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Wed, 22 Feb 2017 17:55:32 +0100 Subject: [PATCH] Fix file errors in utilities. --- cmd/go-bsdiff/main.go | 5 +++-- cmd/go-bspatch/main.go | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/go-bsdiff/main.go b/cmd/go-bsdiff/main.go index 9cb6471..c13b5b4 100644 --- a/cmd/go-bsdiff/main.go +++ b/cmd/go-bsdiff/main.go @@ -13,7 +13,7 @@ var ( argOld = cli.Arg("old", "The old file.").Required().ExistingFile() argNew = cli.Arg("new", "The new file.").Required().ExistingFile() - argPatch = cli.Arg("patch", "Where to output the patch file.").Required().File() + argPatch = cli.Arg("patch", "Where to output the patch file.").Required().String() ) func must(err error) { @@ -27,7 +27,8 @@ func must(err error) { func main() { kingpin.MustParse(cli.Parse(os.Args[1:])) - patchFile := *argPatch + patchFile, err := os.Create(*argPatch) + must(err) defer patchFile.Close() oldFile, err := os.Open(*argOld) diff --git a/cmd/go-bspatch/main.go b/cmd/go-bspatch/main.go index e2afa36..4b993ba 100644 --- a/cmd/go-bspatch/main.go +++ b/cmd/go-bspatch/main.go @@ -12,7 +12,7 @@ var ( cli = kingpin.New("go-bspatch", "Applies binary patches generated using the bsdiff algorithm.") 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", "Where the new file will be written to.").Required().String() argPatch = cli.Arg("patch", "The patch file.").Required().ExistingFile() ) @@ -27,13 +27,14 @@ func must(err error) { func main() { kingpin.MustParse(cli.Parse(os.Args[1:])) - newFile := *argNew - defer newFile.Close() - oldFile, err := os.Open(*argOld) must(err) defer oldFile.Close() + newFile, err := os.Create(*argNew) + must(err) + defer newFile.Close() + patchFile, err := os.Open(*argPatch) must(err) defer patchFile.Close()