fileutil

package
v0.0.0-...-9a41f76 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fileutil 实现了一些文件操作的基本功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearFile

func ClearFile(path string) error

ClearFile 在路径文件中写入空字符串

func CopyFile

func CopyFile(srcFilePath string, dstFilePath string) error

CopyFile 复制src文件到dest文件

func CreateFile

func CreateFile(path string) bool

CreateFile 在路径中创建一个文件

func FileMode

func FileMode(path string) (fs.FileMode, error)

FileMode 返回文件的模式和权限

func IsDir

func IsDir(path string) bool

IsDir 检查路径是否为目录

func IsExist

func IsExist(path string) bool

IsExist 检查一个文件或目录是否存在

func IsLink(path string) bool

IsLink 检查一个文件是否是符号链接

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir 如果不存在则新建文件夹

func ListFileNames

func ListFileNames(path string) ([]string, error)

ListFileNames 返回路径中的所有文件名

func MiMeType

func MiMeType(file any) string

MiMeType 返回文件的mime类型 参数 `file`应该是字符串(文件路径)或*os.File

func MkDir

func MkDir(src string) error

MkDir 新建文件夹

func ReadFileByLine

func ReadFileByLine(path string) ([]string, error)

ReadFileByLine 逐行读取文件

func ReadFileToString

func ReadFileToString(path string) (string, error)

ReadFileToString 返回文件内容的字符串

func RemoveFile

func RemoveFile(path string) error

RemoveFile 删除路径中的文件

func UnZip

func UnZip(zipFile string, destPath string) error

UnZip 解压缩文件并将其保存到destPath

func Zip

func Zip(filePath string, destPath string) error

Zip 创建压缩文件, 参数`filePath`可以是一个单独的文件或一个目录

Types

This section is empty.

Jump to

Keyboard shortcuts

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