gspath

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

搜索目录管理. 可以添加搜索目录,按照添加的优先级进行文件检索,并在内部进行高效缓存处理。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SPath

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

文件目录搜索管理对象

func New

func New() *SPath

创建一个搜索对象

func (*SPath) Add

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

添加搜索路径

func (*SPath) AllPaths added in v1.2.10

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

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

func (*SPath) Remove added in v1.2.10

func (sp *SPath) Remove(path string)

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

func (*SPath) Search

func (sp *SPath) Search(name string, indexFiles ...string) (path string, isDir bool)

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

func (*SPath) Set

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

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

func (*SPath) Size

func (sp *SPath) Size() int

当前的搜索路径数量

type SPathCacheItem added in v1.2.10

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

文件搜索缓存项

Jump to

Keyboard shortcuts

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