Documentation ¶
Overview ¶
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const ( // CHECKSUM_MD5 获取文件的 md5 值 CHECKSUM_MD5 int = 1 << iota // CHECKSUM_CRC32 获取文件的 crc32 值 CHECKSUM_CRC32 // CHECKSUM_SHA1 获取文件的 sha1 值 CHECKSUM_SHA1 )
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 LocalFileEntity ¶
type LocalFileEntity struct { LocalFileMeta // contains filtered or unexported fields }
LocalFileEntity 校验本地文件
func GetFileSum ¶
func GetFileSum(localPath string, flag int) (lfc *LocalFileEntity, err error)
GetFileSum 获取文件的大小, md5, crc32
func NewLocalFileEntity ¶
func NewLocalFileEntity(localPath string) *LocalFileEntity
func NewLocalFileEntityWithBufSize ¶
func NewLocalFileEntityWithBufSize(localPath string, bufSize int) *LocalFileEntity
func (*LocalFileEntity) OpenPath ¶
func (lfc *LocalFileEntity) OpenPath() error
OpenPath 检查文件状态并获取文件的大小 (Length)
func (*LocalFileEntity) Sum ¶
func (lfc *LocalFileEntity) Sum(checkSumFlag int) (err error)
Sum 计算文件摘要值
type LocalFileMeta ¶
type LocalFileMeta struct { Path string `json:"path,omitempty"` // 本地路径 Length int64 `json:"length,omitempty"` // 文件大小 MD5 string `json:"md5,omitempty"` // 文件的 md5 CRC32 uint32 `json:"crc32,omitempty"` // 文件的 crc32 SHA1 string `json:"sha1,omitempty"` // 文件的 sha1 ModTime int64 `json:"modtime"` // 修改日期 // 网盘上传参数 UploadOpEntity *aliyunpan.CreateFileUploadResult `json:"uploadOpEntity"` // ParentFolderId 存储云盘的目录ID ParentFolderId string `json:"parent_folder_id,omitempty"` }
LocalFileMeta 本地文件元信息
func (*LocalFileMeta) CompleteAbsPath ¶
func (lfm *LocalFileMeta) CompleteAbsPath()
CompleteAbsPath 补齐绝对路径
func (*LocalFileMeta) EqualLengthMD5 ¶
func (lfm *LocalFileMeta) EqualLengthMD5(m *LocalFileMeta) bool
EqualLengthMD5 检测md5和大小是否相同
func (*LocalFileMeta) EqualLengthSHA1 ¶
func (lfm *LocalFileMeta) EqualLengthSHA1(m *LocalFileMeta) bool
EqualLengthSHA1 检测sha1和大小是否相同