cmdutils

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 16 Imported by: 0

README

cmdutils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CP

type CP struct {
}

CP todo

func (*CP) Copy

func (cp *CP) Copy(dst string, srcs ...string) error

type Tar

type Tar struct {
	// UnpackNextBefore 在 Unpack 时,解析到下一个 Header 后,实际 unpack 前的回调
	UnpackNextBefore func(h *tar.Header) (skip bool, err error)

	// UnpackNextAfter 在 Unpack 时,解析到下一个 Header 后,实际 unpack 后的回调
	UnpackNextAfter func(h *tar.Header, err error) error

	// UnCompress Unpack 时的解压缩方法,可选
	// 默认为按照文件后缀自动选择:
	// 1.后缀为 .gz 和 .tgz 时选择 gzip
	UnCompress func(rd io.Reader) (io.Reader, error)

	// StripComponents Unpack 的时候,忽略掉前 N 层目录
	StripComponents uint

	// MinSize 最小文件大小,>0 时有效
	MinSize int64

	// MaxSize 最小文件大小,>0 时有效
	MaxSize int64

	// IgnoreFailed 是否忽略异常
	// 不会忽略 UnpackNextBefore 返回的 error
	IgnoreFailed bool
}

Tar tape archive 工具,目前已经具备压缩文件

func (*Tar) Unpack

func (tr *Tar) Unpack(archiveFile string, targetDir string) error

Unpack 解压缩文件到指定目录

func (*Tar) UnpackFromReader

func (tr *Tar) UnpackFromReader(trd *tar.Reader, targetDir string) error

type Wget

type Wget struct {
	LogWriter io.Writer

	Proxy func(*http.Request) (*url.URL, error)

	// Timeout 整体超时
	Timeout time.Duration

	// ConnectTimeout 连接超时
	ConnectTimeout time.Duration

	InsecureSkipVerify bool
}

func (*Wget) Download

func (w *Wget) Download(src string, dst string) error

func (*Wget) DownloadToWriter

func (w *Wget) DownloadToWriter(src string, dst io.Writer) error

type Zip

type Zip struct {
	// UnpackNextBefore 在 Unpack 时,解析到下一个 Header 后,实际 unpack 前的回调
	UnpackNextBefore func(f *zip.File) (skip bool, err error)

	// UnpackNextAfter 在 Unpack 时,解析到下一个 Header 后,实际 unpack 后的回调
	UnpackNextAfter func(f *zip.File, err error) error

	// StripComponents Unpack 的时候,忽略掉前 N 层目录
	StripComponents uint

	// MinSize 最小文件大小,>0 时有效
	MinSize int64

	// MaxSize 最小文件大小,>0 时有效
	MaxSize int64

	// IgnoreFailed 是否忽略异常
	// 不会忽略 UnpackNextBefore 返回的 error
	IgnoreFailed bool
}

func (*Zip) Unpack

func (zp *Zip) Unpack(archiveFile string, targetDir string) error

Unpack 解压缩文件到指定目录

func (*Zip) UnpackFromReader

func (zp *Zip) UnpackFromReader(zrd *zip.Reader, targetDir string) error

Directories

Path Synopsis
examples
tar
zip

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL