Documentation
¶
Overview ¶
Package tarcopy provides functions for copying files over a channel via a tar stream.
Index ¶
Constants ¶
const (
// custom flag to indicate that the source is a single file
SingleFile = "singlefile"
)
Variables ¶
This section is empty.
Functions ¶
func TarCopyDest ¶
func TarCopyDest(ctx context.Context, cancel context.CancelCauseFunc, ch <-chan wshrpc.RespOrErrorUnion[iochantypes.Packet], readNext func(next *tar.Header, reader *tar.Reader, singleFile bool) error) error
TarCopyDest reads a tar stream from a channel and writes the files to the destination. readNext is a function that is called for each file in the tar stream to read the file data. If only a single file is being written from the tar src, the singleFile flag will be set in this callback. It should return an error if the file cannot be read. The function returns an error if the tar stream cannot be read.
func TarCopySrc ¶
func TarCopySrc(ctx context.Context, pathPrefix string) (outputChan chan wshrpc.RespOrErrorUnion[iochantypes.Packet], writeHeader func(fi fs.FileInfo, file string, singleFile bool) error, writer io.Writer, close func())
TarCopySrc creates a tar stream writer and returns a channel to send the tar stream to. writeHeader is a function that writes the tar header for the file. If only a single file is being written, the singleFile flag should be set to true. writer is the tar writer to write the file data to. close is a function that closes the tar writer and internal pipe writer.
Types ¶
This section is empty.