fsutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: MIT Imports: 13 Imported by: 0

README

fsutil 文件处理工具

大文件处理

  • fsutil.BlockRead(filename, handle) 分块读取大文件,每次读取 4M 内容

文件下载

  • fsutil.Download 下载远程文件

文件及目录处理

  • fsutil.Exist(filename) 判断文件是否存在

  • fsutil.PathExist(path) 判断路径/目录是否存在

  • fsutil.IsDir(path) 判断所给路径是否为文件夹

  • fsutil.Clear(filepath) 清理目录下的所有文件

  • fsutil.Copy(src, dst) 复制文件,并自动创建不存在的目录,如果文件已存在则覆盖

  • fsutil.CopyFile(src, dst, overview) 复制文件,并自动创建不存在的目录

  • fsutil.CopyPath(src, dst) 递归复制目录,并自动创建不存在的目录,如果文件已存在则覆盖

  • fsutil.Read2Base64(path string) 读文件并返回内容的 base64 编码,一般用在图片处理时。

  • fsutil.QiNiuFileHash(filename) 获得文件内容的 hash

  • fsutil.QiNiuHash(reader, size) 获得指定长度内容的 hash

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockRead

func BlockRead(fileName string, handle func([]byte) error) error

BlockRead 分块读取大文件,每次读取 4M 内容

func Clear

func Clear(filePath string) error

Clear 清理目录下的所有文件

func Copy

func Copy(src, dst string) (int64, error)

Copy 复制文件

func CopyFile

func CopyFile(src, dst string, overwrite bool) (int64, error)

CopyFile 复制文件

func CopyPath

func CopyPath(src, dst string) error

CopyPath 拷贝目录

func Download

func Download(filename, remoteUrl string) error

Download 下载远程文件

func Exist

func Exist(filename string) bool

Exist 判断文件是否存在

func IsDir

func IsDir(path string) bool

IsDir 判断所给路径是否为文件夹

func PathExist

func PathExist(path string) bool

PathExist 判断路径/目录是否存在

func QiNiuFileHash

func QiNiuFileHash(filepath string) (string, error)

QiNiuFileHash 获得文件内容的 hash

func QiNiuHash

func QiNiuHash(f io.Reader, fsize int64) (etag string, err error)

QiNiuHash 获得内容的 hash

func Read2Base64

func Read2Base64(path string) (string, error)

Read2Base64 读文件并返回内容的 `base64` 编码。 一般用在图片处理时

Types

This section is empty.

Jump to

Keyboard shortcuts

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