Merge pull request #226 from harshavardhana/pr_out_donut_gen_works_with_new_donut_frame

This commit is contained in:
Harshavardhana 2015-02-28 16:30:34 -08:00
commit 24c5ab70be
1 changed files with 58 additions and 62 deletions

View File

@ -1,65 +1,61 @@
// +build ignore
package main package main
// +build ignore import (
func main() {} "bytes"
"fmt"
"os"
"reflect"
// "github.com/minio-io/minio/pkg/storage/donut/v1"
//import ( )
// "bytes"
// "fmt" func main() {
// "os" fmt.Println("--start")
// "reflect"
// file, err := os.OpenFile("newfile", os.O_WRONLY|os.O_CREATE, 0666)
// "github.com/minio-io/minio/pkg/storage/donut/v1" if err != nil {
//) panic(err)
// }
//func main() { data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
// fmt.Println("--start")
// dataBuffer := bytes.NewBuffer(data)
// file, err := os.OpenFile("newfile", os.O_WRONLY|os.O_CREATE, 0666)
// if err != nil { err = v1.Write(file, dataBuffer, uint64(dataBuffer.Len()))
// panic(err) if err != nil {
// } panic(err)
// donut := v1.Write(file) }
// file.Close()
// gobHeader := v1.GobHeader{} fmt.Println("--closed")
// data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
// fmt.Println("--verify")
// dataBuffer := bytes.NewBuffer(data) stat, _ := os.Stat("newfile")
// err = donut.Write(gobHeader, dataBuffer) fileSize := stat.Size()
// if err != nil {
// panic(err) rfile, _ := os.OpenFile("newfile", os.O_RDONLY, 0666)
// } blockStart := make([]byte, 4)
// file.Close() blockStartCheck := []byte{'M', 'I', 'N', 'I'}
// fmt.Println("--closed")
// _, err = rfile.Read(blockStart)
// fmt.Println("--verify") if err != nil {
// stat, _ := os.Stat("newfile") panic(err)
// fileSize := stat.Size() }
//
// rfile, _ := os.OpenFile("newfile", os.O_RDONLY, 0666) blockEnd := make([]byte, 4)
// blockStart := make([]byte, 4) start := fileSize - 4
// blockStartCheck := []byte{'M', 'I', 'N', 'I'} blockEndCheck := []byte{'I', 'N', 'I', 'M'}
// rfile.ReadAt(blockEnd, start)
// _, err = rfile.Read(blockStart) rfile.Close()
// if err != nil {
// panic(err) if !reflect.DeepEqual(blockStart, blockStartCheck) {
// } panic("Corrupted donut file")
// }
// blockEnd := make([]byte, 4)
// start := fileSize - 4 if !reflect.DeepEqual(blockEnd, blockEndCheck) {
// blockEndCheck := []byte{'I', 'N', 'I', 'M'} panic("Corrupted donut file")
// rfile.ReadAt(blockEnd, start) }
// rfile.Close()
// fmt.Println("--verified")
// if !reflect.DeepEqual(blockStart, blockStartCheck) { fmt.Println("--end")
// panic("Corrupted donut file") }
// }
//
// if !reflect.DeepEqual(blockEnd, blockEndCheck) {
// panic("Corrupted donut file")
// }
//
// fmt.Println("--verified")
// fmt.Println("--end")
//}