Refactored Hash -> Sum and fixed infinite loop issue with SumAtoms

This commit is contained in:
David Howden
2015-04-03 15:13:39 +11:00
parent 208a9e993c
commit e9deeea0e1
2 changed files with 28 additions and 24 deletions
+37
View File
@@ -0,0 +1,37 @@
// Copyright 2015, David Howden
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
The sum tool constructs a checksum of a media file exluding any metadata
(as recognised by the tag library).
*/
package main
import (
"fmt"
"os"
"github.com/dhowden/tag"
)
func main() {
if len(os.Args) != 2 {
fmt.Printf("usage: %v filename\n", os.Args[0])
return
}
f, err := os.Open(os.Args[1])
if err != nil {
fmt.Printf("error loading file: %v", err)
os.Exit(1)
}
defer f.Close()
h, err := tag.Sum(f)
if err != nil {
fmt.Printf("error constructing checksum: %v\n", err)
os.Exit(1)
}
fmt.Println(h)
}