fileutil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

fileutil

文件处理工具

  • 文件操作
  • 文件解压缩

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileExisted

func CheckFileExisted(filePath string, timeout time.Duration) error

CheckFileExisted 检测单个文件是否存在

func CheckMultiFileExisted

func CheckMultiFileExisted(timeout, interval time.Duration, filePaths ...string) (string, error)

CheckMultiFileExisted 检查多个文件是否存在且修改时间大于interval

func CopyDir

func CopyDir(srcPath, desPath string) error

CopyDir 复制整个文件夹

func CopyFileByIoCopy

func CopyFileByIoCopy(src, des string) (written int64, err error)

CopyFileByIoCopy 使用io.Copy文件, 复制文件过程中一定要注意将原始文件的权限也要复制过去,否则可能会导致可执行文件不能执行等问题

func CopyFileByIoUtil

func CopyFileByIoUtil(src, des string) (written int64, err error)

CopyFileByIoUtil 使用ioutil.WriteFile()和ioutil.ReadFile() 复制文件

func CopyFileByOs

func CopyFileByOs(src, des string, bufSize int) (written int64, err error)

CopyFileByOs 使用os.Read()和os.Write()复制文件

func CreateFile

func CreateFile(Path string) (*os.File, error)

CreateFile 创建文件, 需要Close

func FileIsExisted

func FileIsExisted(filename string) bool

FileIsExisted 文件是否存在

func GetFileModTime

func GetFileModTime(filename string) (time.Time, error)

GetFileModTime 获取文件修改时间

func GetFileSize

func GetFileSize(filename string) (int64, error)

GetFileSize 获取文件大小

func IsDir

func IsDir(name string) bool

IsDir 是否是目录

func ListDir

func ListDir(dir, suffix string) (files []string, err error)

ListDir 遍历指定文件夹中的所有文件(不进入下一级子目录) 获取指定路径下的所有文件及文件夹,只搜索当前路径,不进入下一级目录,可匹配后缀过滤(suffix为空则不过滤)

func MakeDir

func MakeDir(dir string) error

MakeDir 创建文件夹

func ReadFile

func ReadFile(filename string) ([]byte, error)

ReadFile 读取文件

func RemoveAll

func RemoveAll(dir string) error

RemoveAll 删除文件夹及其包含的所有子目录和所有文件

func RemoveFile

func RemoveFile(filename string) error

RemoveFile 删除文件

func RenameFile

func RenameFile(oldPath, newPath string) error

RenameFile 重命名文件

func ReplacePathExt

func ReplacePathExt(path, newExt string) string

ReplacePathExt 替换后缀名

func WalkDir

func WalkDir(dir, suffix string) (files []string, err error)

WalkDir 遍历指定路径及其子目录中的所有文件 获取指定路径下以及所有子目录下的所有文件,可匹配后缀过滤(suffix为空则不过滤)

func WriteDataToFile

func WriteDataToFile(filePath string, data interface{}) error

WriteDataToFile 写数据到文件

func ZipCompress

func ZipCompress(dest string, src ...string) error

ZipCompress dest 为zip目录, src, otherSrc...为压缩文件或文件夹

func ZipDeCompress

func ZipDeCompress(zipFile, dest string) error

ZipDeCompress 解压

Types

This section is empty.

Jump to

Keyboard shortcuts

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