lz4 icon indicating copy to clipboard operation
lz4 copied to clipboard

Add lz4.AppendOption for NewWriter

Open xiaojun207 opened this issue 2 years ago • 0 comments

Add lz4.AppendOption, if NewWriter set lz4.AppendOption(true) ,then will not write header.

In this way, you can continue to write new data on the existing lz4 file.

like this:

        // 
	fw, _ := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)
	w := lz4.NewWriter(fw)

	w.Apply(lz4.ChecksumOption(false))

	w.Write(d)
	w.Flush()

        // do some other  thing, or a long time later

        
	fw, _ := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)
	w := lz4.NewWriter(fw)

	w.Apply(lz4.ChecksumOption(false), lz4.AppendOption(true))

	w.Write(d)
	w.Flush()


Thank

xiaojun207 avatar Oct 12 '22 17:10 xiaojun207