xfile

package
v0.0.0-...-a85f282 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ZipCompressType .zip格式
	ZipCompressType = ".zip"
	// TarGzCompressType .tar.gz 格式
	TarGzCompressType = ".tar.gz"
	// GzCompressType .gz格式
	GzCompressType = ".gz"
)

Variables

This section is empty.

Functions

func EnsureDirExists

func EnsureDirExists(dirPath string) error

EnsureDirExists 确定目录存在

func SafeFileOperation

func SafeFileOperation(filePath string, flag int, perm os.FileMode, operation func(*os.File) error) (*os.File, error)

SafeFileOperation 安全的文件操作

Types

type CompressParam

type CompressParam struct {
	Source      string
	Destination string
	RenameFunc  func(string, string) string // 重命名函数 防止已经有了同名的目标文件
	Format      CompressType                // 指定压缩格式,例如 ".zip", ".tar.gz", ".gz"
	BufferSize  int                         // 缓冲区大小,以字节为单位
	PoolSize    int                         // 临时对象池大小
}

CompressParam 压缩参数

type CompressType

type CompressType string

CompressType 压缩类型

type Compressor

type Compressor interface {
	Compress(param *CompressParam) error
	Decompress(param *DecompressParam) error
}

Compressor 压缩和解压缩接口

type DecompressParam

type DecompressParam struct {
	Source      string
	Destination string
	BufferSize  int // 缓冲区大小,以字节为单位
	PoolSize    int // 临时对象池大小
}

DecompressParam 解压缩参数

type FileCompressor

type FileCompressor struct{}

FileCompressor 文件压缩实例

func (*FileCompressor) Compress

func (fc *FileCompressor) Compress(param *CompressParam) error

Compress 文件压缩方法

func (*FileCompressor) Decompress

func (fc *FileCompressor) Decompress(param *DecompressParam) error

Decompress 文件解压缩方法

Jump to

Keyboard shortcuts

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