Documentation ¶
Overview ¶
Package checksum 校验本地文件包
Index ¶
Constants ¶
View Source
const ( // CHECKSUM_MD5 获取文件的 md5 值 CHECKSUM_MD5 int = 1 << iota // CHECKSUM_SLICE_MD5 获取文件前 sliceSize 切片的 md5 值 CHECKSUM_SLICE_MD5 // CHECKSUM_CRC32 获取文件的 crc32 值 CHECKSUM_CRC32 )
View Source
const ( // DefaultBufSize 默认的bufSize DefaultBufSize = int(256 * converter.KB) )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ChecksumWriteUnit ¶
type ChecksumWriteUnit struct { SliceEnd int64 End int64 SliceSum interface{} Sum interface{} OnlySliceSum bool ChecksumWriter ChecksumWriter // contains filtered or unexported fields }
type ChecksumWriter ¶
func NewHash32ChecksumWriter ¶
func NewHash32ChecksumWriter(h32 hash.Hash32) ChecksumWriter
func NewHashChecksumWriter ¶
func NewHashChecksumWriter(h hash.Hash) ChecksumWriter
type LocalFileChecksum ¶
type LocalFileChecksum struct { LocalFileMeta // contains filtered or unexported fields }
LocalFileChecksum 校验本地文件
func GetFileSum ¶
func GetFileSum(localPath string, flag int) (lfc *LocalFileChecksum, err error)
GetFileSum 获取文件的大小, md5, 前256KB切片的 md5, crc32
func NewLocalFileChecksum ¶
func NewLocalFileChecksum(localPath string, sliceSize int) *LocalFileChecksum
func NewLocalFileChecksumWithBufSize ¶
func NewLocalFileChecksumWithBufSize(localPath string, bufSize, sliceSize int) *LocalFileChecksum
func (*LocalFileChecksum) OpenPath ¶
func (lfc *LocalFileChecksum) OpenPath() error
OpenPath 检查文件状态并获取文件的大小 (Length)
func (*LocalFileChecksum) Sum ¶
func (lfc *LocalFileChecksum) Sum(checkSumFlag int) (err error)
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和大小是否相同
Click to show internal directories.
Click to hide internal directories.