github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/store/util.go (about)

     1  package store
     2  
     3  import (
     4  	"github.com/balzaczyy/golucene/core/codec"
     5  )
     6  
     7  /*
     8  Clones the provided input, reads all bytes from the file, and calls
     9  CheckFooter().
    10  
    11  Note that this method may be slow, as it must process the entire file.
    12  If you just need to extract the checksum value, call retrieveChecksum().
    13  */
    14  func ChecksumEntireFile(input IndexInput) (hash int64, err error) {
    15  	clone := input.Clone()
    16  	if err = clone.Seek(0); err != nil {
    17  		return 0, err
    18  	}
    19  	in := newBufferedChecksumIndexInput(clone)
    20  	assert(in.FilePointer() == 0)
    21  	if err = in.Seek(in.Length() - codec.FOOTER_LENGTH); err != nil {
    22  		return 0, err
    23  	}
    24  	return codec.CheckFooter(in)
    25  }