checksum

package
v3.5.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package checksum 校验本地文件包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalFile

type LocalFile struct {
	LocalFileMeta

	File *os.File // 文件
	// contains filtered or unexported fields
}

LocalFileInfo LocalFile

func GetFileSum

func GetFileSum(localPath string, cfg *SumConfig) (lf *LocalFile, err error)

GetFileSum 获取文件的大小, md5, 前256KB切片的 md5, crc32

func NewLocalFileInfo

func NewLocalFileInfo(localPath string, bufSize int) *LocalFile

func (*LocalFile) Close

func (lf *LocalFile) Close() error

Close 关闭文件

func (*LocalFile) Crc32Sum

func (lf *LocalFile) Crc32Sum()

Crc32Sum 获取文件的 crc32 值

func (*LocalFile) Md5Sum

func (lf *LocalFile) Md5Sum()

Md5Sum 获取文件的 md5 值

func (*LocalFile) OpenPath

func (lf *LocalFile) OpenPath() error

OpenPath 检查文件状态并获取文件的大小 (Length)

func (*LocalFile) SliceMD5Sum

func (lf *LocalFile) SliceMD5Sum()

SliceMD5Sum 获取文件前 requiredSliceLen (256KB) 切片的 md5 值

func (*LocalFile) Sum

func (lf *LocalFile) Sum(cfg SumConfig)

Sum 计算文件摘要值

type LocalFileMeta

type LocalFileMeta struct {
	Path     string `json:"path"`     // 本地路径
	Length   int64  `json:"length"`   // 文件大小
	SliceMD5 []byte `json:"slicemd5"` // 文件前 requiredSliceLen (256KB) 切片的 md5 值
	MD5      []byte `json:"md5"`      // 文件的 md5
	CRC32    uint32 `json:"crc32"`    // 文件的 crc32
	ModTime  int64  `json:"modtime"`  // 修改日期
}

LocalFileMeta 本地文件元信息

func (*LocalFileMeta) CompleteAbsPath

func (lfm *LocalFileMeta) CompleteAbsPath()

CompleteAbsPath 补齐绝对路径

func (*LocalFileMeta) EqualLengthMD5

func (lfm *LocalFileMeta) EqualLengthMD5(m *LocalFileMeta) bool

EqualLengthMD5 检测md5和大小是否相同

type SumConfig

type SumConfig struct {
	IsMD5Sum      bool
	IsSliceMD5Sum bool
	IsCRC32Sum    bool
}

SumConfig 计算文件摘要值配置

Jump to

Keyboard shortcuts

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