fileutils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDir

func CreateDir(dirPath string, perms ...os.FileMode) error

创建文件夹(递归) @param perm 权限 0777(读4写2执行1)

func Delete

func Delete(path string, forces ...bool) error

删除文件或文件夹 @param force 强制删除非空的文件夹

func GetAllPaths

func GetAllPaths(dirPath string, exts ...string) (dirPaths []string, filePaths []string, err error)

获取所有文件和文件夹的路径,包含子文件夹下的文件和文件夹 @param ext 过滤文件,只获取匹配后缀名的文件,示例:.go

func GetContentType

func GetContentType(ext string) string

根据文件名或扩展名获取ContentType

func GetFileType

func GetFileType(fileName string) string

获取文件类型

func GetNames

func GetNames(dirPath string, exts ...string) (dirNames []string, fileNames []string, err error)

获取所有文件和文件夹的文件名 @param ext 过滤文件,只获取匹配后缀名的文件,示例:.go

func GetPaths

func GetPaths(dirPath string, exts ...string) (dirPaths []string, filePaths []string, err error)

获取所有文件和文件夹的路径 @param ext 过滤文件,只获取匹配后缀名的文件,示例:.go

func GetWorkDir

func GetWorkDir() string

获取的当前运行路径

func IsExist

func IsExist(path string) bool

判断文件或文件夹否存在

func Name

func Name(filePath string) string

获取文件路径中的文件名(包括扩展名)

func NameNoExt

func NameNoExt(filePath string) string

获取文件路径中的文件名(不包括扩展名)

func ReadFile

func ReadFile(filePath string) (string, error)

读取文本文件内容

func WriteFile

func WriteFile(filePath string, body string, forces ...bool) error

写入文本文件内容 @param force 文件夹不存在时自动创建

Types

This section is empty.

Jump to

Keyboard shortcuts

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