From a15e935a3383f44097f14795747d85fc56699375 Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Sat, 22 Nov 2014 11:17:53 -0800 Subject: [PATCH] Adding minio-encode binary --- Makefile | 1 + cmd/minio-encode/main.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 cmd/minio-encode/main.go diff --git a/Makefile b/Makefile index 077bf5274..953b07f47 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ test: build-erasure godep go test -race -coverprofile=cover.out github.com/minio-io/minio install: build-erasure + godep go install github.com/minio-io/minio/cmd/minio-encode save: godep save ./... diff --git a/cmd/minio-encode/main.go b/cmd/minio-encode/main.go new file mode 100644 index 000000000..6833a0e21 --- /dev/null +++ b/cmd/minio-encode/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "io/ioutil" + "log" + "os" + "strconv" + + "github.com/codegangsta/cli" + "github.com/minio-io/minio/erasure" +) + +func main() { + app := cli.NewApp() + app.Name = "minio-encode" + app.Usage = "erasure encode a byte stream" + app.Action = func(c *cli.Context) { + erasureParameters, _ := erasure.ValidateParams(10, 5, 8, erasure.VANDERMONDE) + + encoder := erasure.NewEncoder(erasureParameters) + input, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatal("Error reading stdin") + } + encodedData, _ := encoder.Encode(input) + for key, data := range encodedData { + ioutil.WriteFile("output."+strconv.Itoa(key), data, 0600) + } + } + app.Run(os.Args) +}