xpath

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(root string, name string, indexFiles ...string) (filePath string, isDir bool)

检索root目录(必须为绝对路径)下面的name文件的绝对路径,indexFiles用于指定当检索到的结果为目录时,同时检索是否存在这些indexFiles文件

func SearchWithCache

func SearchWithCache(root string, name string, indexFiles ...string) (filePath string, isDir bool)

检索root目录(必须为绝对路径)下面的name文件的绝对路径,indexFiles用于指定当检索到的结果为目录时,同时检索是否存在这些indexFiles文件

Types

type TPath

type TPath struct {
	// contains filtered or unexported fields
}

文件目录搜索管理对象

func Get

func Get(root string, cache bool) *TPath

创建/获取一个单例的搜索对象, root必须为目录的绝对路径

func New

func New(path string, cache bool) *TPath

创建一个搜索对象

func (*TPath) Add

func (sp *TPath) Add(path string) (realPath string, err error)

添加搜索路径

func (*TPath) AllPaths

func (sp *TPath) AllPaths() []string

返回当前对象缓存的所有路径列表

func (*TPath) Paths

func (sp *TPath) Paths() []string

返回当前对象搜索目录路径列表

func (*TPath) Remove

func (sp *TPath) Remove(path string)

从搜索路径中移除指定的文件,这样该文件无法给搜索。 path可以是绝对路径,也可以相对路径。

func (*TPath) Search

func (sp *TPath) Search(name string, indexFiles ...string) (filePath string, isDir bool)

给定的name只是相对文件路径,找不到该文件时,返回空字符串; 当给定indexFiles时,如果name是一个目录,那么会进一步检索其下对应的indexFiles文件是否存在,存在则返回indexFile绝对路径; 否则返回name目录绝对路径。

func (*TPath) Set

func (sp *TPath) Set(path string) (realPath string, err error)

设置搜索路径,只保留当前设置项,其他搜索路径被清空

func (*TPath) Size

func (sp *TPath) Size() int

当前的搜索路径数量

type TPathCacheItem

type TPathCacheItem struct {
	// contains filtered or unexported fields
}

文件搜索缓存项

Jump to

Keyboard shortcuts

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