files

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileIsExist

func CheckFileIsExist(file string) bool

CheckFileIsExist 检查文件或路径是否存在

func CheckFileIsPermission

func CheckFileIsPermission(src string) bool

CheckFileIsPermission 检查文件或路径是否有权限操作

func CheckPathIsDir

func CheckPathIsDir(path string) bool

CheckPathIsDir 判断是否为路径

func CopyFile

func CopyFile(srcName string, dstName string) (int64, error)

CopyFile 封装的文件拷贝方法,srcName源文件, dstName目标文件

func GetAllFiles

func GetAllFiles(dirPth string, childDir bool, extensions []string) (files []string, err error)

GetAllFiles 获取指定目录下的所有文件; childDir = true 代表输出子目录下的文件; ext代表后缀名,如果为空则输出全部类型的文件,如果不为空,则输出指定类型的文件;

func GetAppRootWDPath

func GetAppRootWDPath() (string, error)

GetAppRootWDPath 获取项目根路径目录

func GetFileExt

func GetFileExt(fileName string) string

GetFileExt 获取文件后缀

func GetFileNameInfo

func GetFileNameInfo(filename string) (nameInfo, ext string)

GetFileNameInfo 获取文件的名称和后缀名信息,filename可以是test.txt,也可以是/root/test/test.txt之类的 nameInfo代表除去后缀名的文件名,ext代表后缀名

func GetFileSize

func GetFileSize(file multipart.File) (int, error)

GetFileSize 获取文件大小

func GetFilesAndDirs

func GetFilesAndDirs(dirPth string, extensions []string) (files []string, dirs []string, err error)

GetFilesAndDirs 获取指定目录下的所有文件名和目录

func IsNotExistToMkDir

func IsNotExistToMkDir(src string) (newDir bool, err error)

IsNotExistToMkDir 目录如果不存在则新建文件夹,新建文件夹失败则返回错误,newDir代表这个目录是不是刚刚新建的目录(即这是一个空目录)

func MustOpen

func MustOpen(fileName, filePath string) (file *os.File, err error)

MustOpen 最大限度地尝试打开文件

func ToMkdir

func ToMkdir(dirName string) error

ToMkdir 新建文件夹,新建文件夹失败则返回错误

func WriteLines

func WriteLines(dir string, filename string, dataLines []string, lineEnding string, writeTime bool, append bool) error

WriteLines 按行写入文件,dir指的是路径,filename指的是文件名,dataLines指的是具体的数据,lineEnding指的是分割符,如\n, writeTime指是否需要在行首写入时间,append指是否需要追加写入

Types

This section is empty.

Jump to

Keyboard shortcuts

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