Documentation ¶
Overview ¶
Package xzwriter provides a WriteCloser XZWriter that pipes through an external XZ compressor.
Expects the Tukaani XZ tool in $PATH. See the XZ Utils home page: <http://tukaani.org/xz/>
Index ¶
Constants ¶
const ( Fast = 0 Default = 6 Best = 9 )
Variables ¶
var (
ErrOptionIllegal = errors.New("option illegal")
)
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v0.1.2
func WithCompressLevel ¶ added in v0.1.2
WithCompressLevel sets the compression level between 0 and 9. The constants `Fast`, `Default` and `Best` correspond to the flags `--fast`, `--default` and `--best`.
func WithSeparateProcessGroup ¶ added in v0.1.2
func WithSeparateProcessGroup() Option
WithSeparateProcessGroup set's the process group of the `xz` subprocess to its own, separate process group. When the program using this library is started in a shell session, hitting CTRL+C will send an interrupt signal to both processes. That means that the `xz` process terminates immediately without reading STDIN to its end, instead writes to the xzwriter fails with ERRPIPE.
If the program using this library wants to handle the SIGINT gracefully, one needs to prevent the shell from sending the SIGINT to the xz subprocess also. Running `xz` in a separate process group achieves that.
func WithVerbose ¶ added in v0.1.2
WithVerbose sets verbosity and takes a writer that will be connected to STDERR of the xz subprocess. This provides a nice progress output to look at.
type XZWriter ¶
type XZWriter struct {
// contains filtered or unexported fields
}
XZWriter is a WriteCloser that wraps a writer around an XZ compressor.
func NewWithContext ¶
NewWithContext returns an XZWriter, wrapping the writer w. The context may be used to cancel or timeout the external compressor process.
The context can be used to kill the external process early. You still need to call Close() to clean up ressources. Alternatively you may call Close() prematurely.
func NewWithOptions ¶ added in v0.1.2
NewWithOptions returns an XZWriter, wrapping the writer w. The context may be used to cancel or timeout the external compressor process.
The context can be used to kill the external process early. You still need to call Close() to clean up ressources. Alternatively you may call Close() prematurely.
The compressor process can be configured with options.