xfile

package
v0.0.0-...-bb5f27f Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetParentPath

func GetParentPath(path string) string

* 获取给定路径的上级目录路径,返回的上级目录中,不包含 / 结尾 实例: /data/web/log --> /data/web E:\data\web\log --> E:\data\web / --> "" /data --> ""

func IsDirExists

func IsDirExists(path string) bool

* 判断给定的 文件路径是否是一个存在的目录

func IsFileExists

func IsFileExists(path string) bool

* 给定路径文件是否存在

func ReadAsMap

func ReadAsMap(filePath string) (kvs map[string]string, err error)

* 解析为 kvs map

func ReadPropertiesAsMap

func ReadPropertiesAsMap(propertiesFile string) (kvs map[string]string, err error)

* 读取配置

func ReadYamlAsMap

func ReadYamlAsMap(yamlFile string) (kvs map[string]string, err error)

* 将 Yaml 文件读取出来,作为 key value 格式

func ScanParent

func ScanParent(path string, consumer func(parent *FileInfo) (stop bool)) error

* 扫描父级文件,直到没有父级为止 @param path 源文件 @param consumer 当扫描到父级目录的时候,执行consumer处理,返回true则不会继续往上扫描 @return error 如果扫描异常则返回 error

Types

type FileInfo

type FileInfo struct {
	Info   os.FileInfo
	Path   string    // 文件全路径
	Parent *FileInfo // 上级目录
}

func ListDirFiles

func ListDirFiles(dir string, acceptor func(pdir string, fileInfo os.FileInfo) bool, depth int) []*FileInfo

* 获取没指定文件夹下的所有文件列表 @param dir 要操作的目录 @param acceptor 过滤器,该接口符合条件的情况下才会返回,如果为 nil 则返回全部 @param depth 扫描深度,有效值>0, 如果传入一个无效值,那么默认就是1,即返回该目录第一层子文件列表, 否则的话,返回第 depth 深度下面的文件

Jump to

Keyboard shortcuts

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