Documentation ¶
Overview ¶
Package dotpath is all about Pathinking - Path..think.ing - Path.ink.ing - Pa.think.ing - Pa.thin.king ...
Package dotpath is intended as a parser for user-provided strings separated by some single character delimiter (which is not a Dot) such as filepath information or other hierarchical identifiers and gives an extended meaning to multiple dots and trailing slashes:
... => 'use Subtree also' - recurse .. => 'use Parent also', if .. is part of trailing dots and slashes ./ => 'this MUST be a directory', if a trailing slash is given
lexical.go: strictly lexical analysis of fullPath
lexical.go uses some dedicated functions exported by pathsplitter.go, and the packages "strings" and "do/string".
Typical use is upon e.g. flag.Args(), flags.StringVar(...)
Index ¶
- Constants
- func DotPathS(args ...string) (dirS []struct{ ... })
- func OneTripleAnyPairs(text string) (segmentS []string)
- func PathDotTailor(head, tail string) []string
- type DotPath
- func (dp *DotPath) HasVolumeName() bool
- func (dp *DotPath) LooksLikeIsAbs() bool
- func (dp *DotPath) LooksLikeIsDir() bool
- func (dp *DotPath) Path() string
- func (dp *DotPath) PathBase() string
- func (dp *DotPath) PathBaseS() (pathBaseS []string)
- func (dp *DotPath) PathName() string
- func (dp *DotPath) PathS() (pathS []string)
- func (dp *DotPath) PathText() string
- func (dp *DotPath) Print()
- func (dp *DotPath) RecursePathS() (pathS []string)
- func (dp *DotPath) Separator() string
- func (dp *DotPath) String() string
- func (dp *DotPath) VolumeName() string
- func (dp *DotPath) WaydownPathS() (pathS []string)
Constants ¶
const ( // Dot represents the period appearing in path names Dot = `.` // SingleDot - just another name for Dot SingleDot = Dot // just another name // DoubleDot represents two consecutive periods `..` appearing in path names DoubleDot = Dot + Dot // TripleDot represents three period `...` appearing in path names TripleDot = Dot + Dot + Dot // Empty represents any empty string Empty = `` )
Combinations of Dots representing the period(s) appearing in path names
const ( // GoPathSeparator is the pathseparator used (but not exported) by standard package `path` GoPathSeparator = `/` // OsPathSeparator is the path-list separator `os.PathSeparator` OsPathSeparator = string(os.PathSeparator) )
Variables ¶
This section is empty.
Functions ¶
func DotPathS ¶
DotPathS - get DirPathS (each with Recurse flag) from args. Uses dotpath functionalities; useful e.g. for commandline arguments.
func OneTripleAnyPairs ¶
OneTripleAnyPairs - a helper to get e.g. '........' as '... .. .. .' Invariant: len(text) == len(segmentS)
func PathDotTailor ¶
PathDotTailor returns a slice of strings each representing a valid node / element / PathBase, or a triple-dot as indicator for a full tree of subdirectories.
Types ¶
type DotPath ¶
type DotPath struct {
// contains filtered or unexported fields
}
DotPath represents a lexically analysed filepath string.
Special attention is given to slashes; especially to trailing slash(es) as indicator for "I mean: directory! Not file.", and to sequences of multiple dots; in particular tripledots "..." as indicators for subtree recursion, and trailing doubledots as indicators for "waydown" accumulation along parents/anchestors.
Hint: Use New(path string) *DotPath for single entries, or Parse(pathNames ...string) for multiple entries.
Note: A DotPath is immutable, and thus concurrency safe.
func FilePathS ¶
FilePathS returns a non-empty slice of NewFilePath
Note: each pathList is split via filepath.SplitList, is expanded against the os environmant, and is normalised via filepath.FromSlash
func New ¶
New returns a parsed *DotPath - separated by sep
Note: sep must have len == 1 and must not be dot
func NewFilePath ¶
NewFilePath returns a parsed *DotPath - separated by the current os.PathSeparator
func PathS ¶
PathS returns a non-empty slice of NewPath
Note: each pathName is not split any further -filepath.SplitList is not applied-, but is normalised via filepath.ToSlash
func (*DotPath) HasVolumeName ¶
HasVolumeName - returns true if some filepath.VolumeName was found
Note: only relevant, if separator == OsPathSeparator, e.g. NewFilePath
func (*DotPath) LooksLikeIsAbs ¶
LooksLikeIsAbs - returns true if some leading Slash was found
func (*DotPath) LooksLikeIsDir ¶
LooksLikeIsDir - returns true if some trailing Slash was found
func (*DotPath) Path ¶
Path - returns the path - less any triple ... dots and any (eventual) trailing slash (including volumename, if any).
func (*DotPath) PathBase ¶
PathBase - returns the path - less any triple ... dots and trailing up .. double dots, (including volumename and trailing delimiter, if any).
func (*DotPath) PathBaseS ¶
PathBaseS returns a slice of strings each representing a node / element / PathBase. The order is last-first / bottom up / reversed. All slashes are gone. VolumeName is ignored.
func (*DotPath) PathName ¶
PathName - returns the full analysed path - incl. any triple ... dots
Note: intentionally, path.Cleaning is is not applied as some tripledot might disappear due to being followed by some doubledot.
func (*DotPath) PathS ¶
PathS conveniently returns any WaydownPath and the Base.
Note: If there is no way down mentioned (and thus: Path and Base are same), the returned list just holds this single element: the Path
func (*DotPath) PathText ¶
PathText - returns the path - less any triple ... dots, (including volumename and trailing delimiter, if any).
func (*DotPath) RecursePathS ¶
RecursePathS returns any (partial) path which ends in a Down ...
func (*DotPath) VolumeName ¶
VolumeName - returns the VolumeName, if any
Note: only relevant, if separator == OsPathSeparator, e.g. NewFilePath
func (*DotPath) WaydownPathS ¶
WaydownPathS returns any (partial) path which is followed by some trailing GoUp ..
Note: such pathS should be considered before PathBase(), and are only relevant if PathText() != PathBase(); Path() would be the first WaydownPath