Documentation ¶
Overview ¶
Package zseek provides a seekable compressed file.
Index ¶
Constants ¶
const ( SeekStart = 0 SeekCur = 1 SeekEnd = 2 )
Constants for Seek
const ( NoCompression = zlib.NoCompression DefaultCompression = zlib.DefaultCompression BestSpeed = zlib.BestSpeed BestCompression = zlib.BestCompression )
Constants for NewLevel and NewBuffer
const (
DefaultBuffer = 32 * 1024
)
Constants for NewBuffer
Variables ¶
var ( ErrEarlyWrite = errors.New("zseek: cannot write before EOF") ErrInvalidSeek = errors.New("zseek: cannot seek outside of file") )
Errors specific to ZSeek
Functions ¶
This section is empty.
Types ¶
type ZSeek ¶
type ZSeek struct {
// contains filtered or unexported fields
}
ZSeek is a seekable compressed file. The file is written in chunks of zlib-compressed data prefixed with a 64-bit little endian integer representing the compressed size of the chunk. ZSeek can only be used as an io.Writer if it is at the end of the file. Attempting to write before reaching the end of the file will return ErrEarlyWrite.
func New ¶
func New(f io.ReadWriteSeeker) (*ZSeek, error)
New is equivalent to calling NewBuffer(f, DefaultCompression, DefaultBuffer).
func NewBuffer ¶
func NewBuffer(f io.ReadWriteSeeker, level, buf int) (*ZSeek, error)
NewBuffer creates a *ZSeek with a specified buffer size for writing. Whenever there are at least buf bytes of unwritten data during a Write call, Flush will automatically be called.
func NewLevel ¶
func NewLevel(f io.ReadWriteSeeker, level int) (*ZSeek, error)
NewLevel is equivalent to calling NewBuffer(f, level, DefaultBuffer).
func (*ZSeek) Close ¶
Close implements io.Closer. Close does not close the underlying io.ReadWriteSeeker. After Close is called, any action on z will return io.ErrClosedPipe.
func (*ZSeek) Flush ¶
Flush writes any buffered data to the underlying io.ReadWriteSeeker. Flush is a no-op if there is no data to be written.
func (*ZSeek) Read ¶
Read implements io.Reader. If a read would cross a chunk boundary, a partial read is done instead. Use io.ReadFull to guarantee a full read.