fileutils

package
v0.0.0-...-a89e01d Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, des string) (w int64, err error)

拷贝文件

func Exist

func Exist(filename string) bool

检查文件或目录是否存在 如果由 filename 指定的文件或目录存在则返回 true,否则返回 false

func ExistDir

func ExistDir(filePath string) bool

是否存在目录

func ExistFile

func ExistFile(filename string) bool

检查文件是否存在 如果由 filename 指定的文件存在则返回 true,否则返回 false(目录也返回错误)

func GetCfgName

func GetCfgName() string

获取配置文件名

func GetFileNameWithoutExtension

func GetFileNameWithoutExtension(path string) string

获取文件名,不带后缀名

func GrepFile

func GrepFile(patten string, filename string) (lines []string, err error)

GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read

func IsSamePath

func IsSamePath(srcPath, dstPath string) bool

比较两个路径是否相等

func ListDir

func ListDir(dirPth string, suffix ...string) ([]string, error)

获取指定目录下的所有文件,不进入下一级目录搜索,可以匹配后缀过滤。

func ReadFile

func ReadFile(path string) (body []byte, err error)

读取文件

func SearchFile

func SearchFile(filename string, paths ...string) (fullpath string, err error)

SearchFile Search a file in paths. this is often used in search config file in /etc ~/

func SelfDir

func SelfDir() string

获取程序运行目录

func SelfPath

func SelfPath() string

获取程序运行文件的绝对路径

func WalkDir

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

获取指定目录及所有子目录下的所有文件,可以匹配后缀过滤。

Types

This section is empty.

Jump to

Keyboard shortcuts

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