代码拉取完成,页面将自动刷新
// Package archive provides tar.gz and zip archiving
package archive
import (
"fmt"
"gitee.com/h79/goutils/common/archive/gzip"
"gitee.com/h79/goutils/common/archive/tar"
"gitee.com/h79/goutils/common/archive/targz"
"gitee.com/h79/goutils/common/archive/tarxz"
"gitee.com/h79/goutils/common/archive/zip"
fileconfig "gitee.com/h79/goutils/common/file/config"
"io"
"os"
)
// Archive represents a compression archive files from disk can be written to.
type Archive interface {
Close() error
Add(f fileconfig.File) error
}
// New archive.
func New(w io.Writer, format string) (Archive, error) {
switch format {
case "tar.gz", "tgz":
return targz.New(w), nil
case "tar":
return tar.New(w), nil
case "gz":
return gzip.New(w), nil
case "tar.xz", "txz":
return tarxz.New(w), nil
case "zip":
return zip.New(w), nil
}
return nil, fmt.Errorf("invalid archive format: %s", format)
}
// Copying copies the source archive into a new one, which can be appended at.
// Source needs to be in the specified format.
func Copying(r *os.File, w io.Writer, format string) (Archive, error) {
switch format {
case "tar.gz", "tgz":
return targz.Copying(r, w)
case "tar":
return tar.Copying(r, w)
case "zip":
return zip.Copying(r, w)
}
return nil, fmt.Errorf("invalid archive format: %s", format)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。