summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2017-01-25 23:59:07 (GMT)
committerChristian Pointner <equinox@helsinki.at>2017-01-25 23:59:07 (GMT)
commit056b224e3241c6cf889ba1c7b0eba85a8f33cc4a (patch)
treedc40054aa1285e86ea31432e9a81b9faa1aef122
parent5624f3ac623ed2caa8c3c3933e66d63aafc09914 (diff)
generate json with absolute paths on stdout
-rw-r--r--src/file-hasher/dir-hasher.go6
-rw-r--r--src/file-hasher/main.go10
2 files changed, 11 insertions, 5 deletions
diff --git a/src/file-hasher/dir-hasher.go b/src/file-hasher/dir-hasher.go
index aa204a0..7f5e45b 100644
--- a/src/file-hasher/dir-hasher.go
+++ b/src/file-hasher/dir-hasher.go
@@ -74,7 +74,11 @@ func handleEntry(C chan<- string, path string, info os.FileInfo, err error, stdl
case ".mp4":
fallthrough
case ".m4a":
- C <- path
+ if absPath, err := filepath.Abs(path); err != nil {
+ stdlog.Printf(" - skipping (%v): %s", err, info.Name())
+ } else {
+ C <- absPath
+ }
default:
stdlog.Printf(" - skipping (unknown extension): %s", info.Name())
}
diff --git a/src/file-hasher/main.go b/src/file-hasher/main.go
index c25f690..1bb0132 100644
--- a/src/file-hasher/main.go
+++ b/src/file-hasher/main.go
@@ -22,6 +22,7 @@
package main
import (
+ "encoding/json"
"log"
"os"
"os/signal"
@@ -68,13 +69,14 @@ func main() {
stdlog.Println("******************************")
}
stdlog.Println("")
- for hash, file := range allFiles {
- stdlog.Printf("%s: %s", hash, file)
- }
- stdlog.Println("")
stdlog.Println("***************************************************************")
stdlog.Printf("*** hashed %d files in %v", len(allFiles), time.Since(starttime))
stdlog.Println("***************************************************************")
+
+ enc := json.NewEncoder(os.Stdout)
+ if err := enc.Encode(allFiles); err != nil {
+ stdlog.Printf("Error encoding JSON: %v", err)
+ }
}()
<-C