filepkg

package
v0.3.25 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DefaultFileMode   os.FileMode = 0744      // 文件权限
	DefaultRuntimeDir             = "runtime" // 临时目录
	DefaultMaxSize                = 20 << 20  // 20M
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(from, to string) error

CopyFile 复制文件

func Hash

func Hash(filePath string) (string, int64, error)

func HashFromFile

func HashFromFile(f io.Reader) (string, int64, error)

func HashIdentifier

func HashIdentifier(filePath string) (string, int64, error)

HashIdentifier 文件标识符; return identifier, size, err identifier = hash + "-" + size;

func HashIdentifierFromFile

func HashIdentifierFromFile(f io.Reader) (string, int64, error)

HashIdentifierFromFile 文件标识符; return identifier, size, err identifier = hash + "-" + size

func Identifier

func Identifier(hash string, size int64) string

Identifier return hash + "-" + size md5(32)+size(19)=51; sha256(64)碰撞概率非常低 可结合mime类型来提高可靠性,mime读取可参考: https://github.com/h2non/filetype; pass the file header = first 261 bytes

func Md5

func Md5(filePath string) (string, int64, error)

Md5 return md5, size, err

func Md5FromFile

func Md5FromFile(f io.Reader) (string, int64, error)

Md5FromFile return md5, size, err

func MoveFileToDir

func MoveFileToDir(filePath, fileDir string) (targetPath string, err error)

MoveFileToDir 移动文件到目录

func Sha256

func Sha256(filePath string) (string, int64, error)

Sha256 return hash, size, err

func Sha256FromFile

func Sha256FromFile(f io.Reader) (string, int64, error)

Sha256FromFile return hash, size, err

Types

This section is empty.

Jump to

Keyboard shortcuts

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