Fix file errors in utilities.

master
Icedream 2017-02-22 17:55:32 +01:00
parent c3d53d04e1
commit 297d5a52a9
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
2 changed files with 8 additions and 6 deletions

View File

@ -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)

View File

@ -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()