diff --git a/examples/README.md b/examples/README.md index 7c5ad53e..c365e9b0 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,7 +6,7 @@ This folder contains usage examples of the Reed-Solomon encoder. Shows basic use of the encoder, and will encode a single file into a number of data and parity shards. This is meant as an example and is not meant for production use -since there is a number of shotcomings noted below. +since there is a number of shortcomings noted below. To build an executable use: @@ -15,7 +15,7 @@ go build simple-decoder.go go build simple-encoder.go ``` -# Streamin API examples +# Streaming API examples There are streaming examples of the same functionality, which streams data instead of keeping it in memory. @@ -26,8 +26,26 @@ go build stream-decoder.go go build stream-encoder.go ``` +# Example usage + +On Windows, the following command will generate six files `README.md.0` to `README.md.5` + +```bash +.\simple-encoder.exe .\README.md +``` + +Rename `README.md` to `README.md.org`, and delete two of the six generated files. The following +command will reconstruct `README.md` from the four generated files. + +```bash +.\simple-decoder.exe .\README.md +``` + +Appreciate that the reconstructed file mau have nul padding as explained in the following shortcomings. + + ## Shortcomings -* If the file size of the input isn't diviable by the number of data shards +* If the file size of the input isn't dividable by the number of data shards the output will contain extra zeroes * If the shard numbers isn't the same for the decoder as in the encoder, invalid output will be generated. @@ -42,4 +60,4 @@ The solution for this is to save a metadata file containing: * HASH of each shard. * Order of the shards. -If you save these properties, you should abe able to detect file corruption in a shard and be able to reconstruct your data if you have the needed number of shards left. +If you save these properties, you should abe able to detect file corruption in a shard and be able to reconstruct your data if you have the needed number of shards left. \ No newline at end of file diff --git a/examples/simple-decoder.go b/examples/simple-decoder.go index 19e91cae..b33163bb 100644 --- a/examples/simple-decoder.go +++ b/examples/simple-decoder.go @@ -38,7 +38,6 @@ package main import ( "flag" "fmt" - "io/ioutil" "os" "github.com/klauspost/reedsolomon" @@ -77,7 +76,7 @@ func main() { for i := range shards { infn := fmt.Sprintf("%s.%d", fname, i) fmt.Println("Opening", infn) - shards[i], err = ioutil.ReadFile(infn) + shards[i], err = os.ReadFile(infn) if err != nil { fmt.Println("Error reading file", err) shards[i] = nil diff --git a/examples/simple-encoder.go b/examples/simple-encoder.go index d90904ca..94a0c461 100644 --- a/examples/simple-encoder.go +++ b/examples/simple-encoder.go @@ -5,7 +5,7 @@ // // Simple encoder example // -// The encoder encodes a simgle file into a number of shards +// The encoder encodes a simple file into a number of shards // To reverse the process see "simpledecoder.go" // // To build an executable use: