fuzzyfs

package module
v0.0.0-...-58713ed Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2014 License: MIT Imports: 5 Imported by: 1

README

fuzzyfs

A Go package for search filsystem ( names ) with some fuzzy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllFiles

func AllFiles(path string, info os.FileInfo) bool

AllFiles match all files..

func DirsAndSymlinksAsDirs

func DirsAndSymlinksAsDirs(path string, info os.FileInfo) bool

DirsAndSymlinksasDirs threat symlinks that are dirs, as dirs, and follow them.

func OnlyDirsPathSelect

func OnlyDirsPathSelect(path string, info os.FileInfo) bool

Only crawl directories

Types

type Dir

type Dir struct {
	Name   string
	Parent *Dir
	Depth  int
}

A Filesystem entry, we store, the node name and Their parents. We only need this info, for later build search and comparasions.. Also we store only the current dir name... this way, when we traverse the list, searching, we can get better results.. Given a path lik /asdf/1/2/asdf we store each segment

func (*Dir) Parents

func (d *Dir) Parents() []*Dir

Parents returns a slice of element Parents

func (*Dir) Path

func (d *Dir) Path() string

Path rejoins the path with their ancestors

func (*Dir) String

func (d *Dir) String() string

String

type DirList

type DirList struct {
	Length     int
	List       []Dir
	MaxDepth   int
	PathSelect PathSelectFn
}

DirList is the main object..

func NewDirList

func NewDirList() *DirList

func (*DirList) Add

func (d *DirList) Add(name string, p *Dir) *Dir

Add a filesystem entry to the List

func (*DirList) Get

func (d *DirList) Get(name string, depth int) *Dir

Traverses Dirlist, and returns a File object for a given name and depth if depth == -1 returns the first ocurrence of name, without matching depth

func (*DirList) GetLength

func (d *DirList) GetLength() int

Size of index

func (*DirList) Populate

func (d *DirList) Populate(path string, Parent *Dir) error

Populate acually traverses the filsystem, storing dir info on the list..

func (*DirList) Query

func (d *DirList) Query(q string, umbral int) Results

Check list against Levenshtein distance and store in Results

type PathSelectFn

type PathSelectFn func(path string, info os.FileInfo) bool

Path selector, is a func for determining if a given path is choosed to be on the index

type Result

type Result struct {
	Path     string `json:"path"`
	Distance int
	Depth    int `json:"depth"`
}

Result is a result for querys

func (Result) String

func (r Result) String() string

type Results

type Results []Result

Results is the list of resultsets

func (Results) Len

func (r Results) Len() int

Sort interface

func (Results) Less

func (r Results) Less(i, j int) bool

Sort by distance and depth

func (Results) Swap

func (r Results) Swap(i, j int)

Directories

Path Synopsis
cmd
fu command
web command

Jump to

Keyboard shortcuts

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