Documentation ¶
Overview ¶
Package fs represents the constituents of a file system and provides type safe access.
See enclosed ReadMe.md for a conceptual overview and further details.
Index ¶
- Constants
- Variables
- func Match(name string, patterns ...*Pattern) (matched bool, err error)
- func MatchDisk(name string) (dirS FsFoldS, filS FsFileS, err error)
- type BaseFriendly
- type DataFriendly
- type DiskFriendly
- type Errors
- type FileFriendly
- type FilePathFriendly
- type FoldFriendly
- type FsBase
- func (p *FsBase) Accessible() error
- func (p *FsBase) AsBase() *FsBase
- func (p *FsBase) AsInfo() *fsInfo
- func (p *FsBase) AsPath() *fsPath
- func (p *FsBase) AsPattern() *Pattern
- func (p *FsBase) Base() *FsBase
- func (p *FsBase) BaseLessExt() *FsBase
- func (p *FsBase) BaseMatches(patterns ...*Pattern) (matched bool, err error)
- func (p *FsBase) Exists() (bool, error)
- func (p *FsBase) Ext() *FsBase
- func (p *FsBase) Glob() (matches []string, err error)
- func (p *FsBase) JoinWith(elem ...string) string
- func (p *FsBase) Match(pattern *Pattern) (matched bool, err error)
- func (p *FsBase) MatchDisk() (dirS FsFoldS, filS FsFileS, err error)
- func (p *FsBase) PathMatches(patterns ...*Pattern) (matched bool, err error)
- func (p *FsBase) Split() (dir, file string)
- func (p *FsBase) SplitList() []string
- func (p *FsBase) Stat() (os.FileInfo, error)
- func (p *FsBase) String() string
- func (p *FsBase) TryBase() (*FsBase, bool)
- func (p *FsBase) TryInfo() (*fsInfo, error)
- func (p *FsBase) TryPath() (*fsPath, bool)
- func (p *FsBase) TryPattern() (*Pattern, bool)
- type FsBaseS
- type FsData
- func (p *FsData) AsFile() *FsFile
- func (p *FsData) AsFold() *FsFold
- func (p *FsData) AsNotDown() *FsFold
- func (p *FsData) AsRecurse() *FsFold
- func (p *FsData) ByteS() []byte
- func (p *FsData) Data() string
- func (p *FsData) Exists() bool
- func (p *FsData) InfoEquals(oi os.FileInfo) bool
- func (p *FsData) IsFold() bool
- func (p *FsData) SameFile(oi os.FileInfo) bool
- func (p *FsData) TryFile() (*FsFile, bool)
- func (p *FsData) TryFold() (*FsFold, bool)
- type FsDataS
- type FsFile
- func (f *FsFile) AsData() *FsData
- func (p *FsFile) AsFile() *FsFile
- func (p *FsFile) AsFold() *FsFold
- func (p *FsFile) AsNotDown() *FsFold
- func (p *FsFile) AsRecurse() *FsFold
- func (p *FsFile) Create() (*os.File, error)
- func (p *FsFile) Exists() bool
- func (p *FsFile) InfoEquals(oi os.FileInfo) bool
- func (p *FsFile) IsFold() bool
- func (p *FsFile) Open() (*os.File, error)
- func (p *FsFile) ReadFile() ([]byte, error)
- func (p *FsFile) SameFile(oi os.FileInfo) bool
- func (f *FsFile) TryData() (*FsData, bool)
- func (p *FsFile) TryFile() (*FsFile, bool)
- func (p *FsFile) TryFold() (*FsFold, bool)
- func (p *FsFile) WriteFile(byteS []byte) error
- type FsFileS
- type FsFold
- func (p *FsFold) AsFile() *FsFile
- func (p *FsFold) AsFold() *FsFold
- func (p *FsFold) AsNotDown() *FsFold
- func (p *FsFold) AsRecurse() *FsFold
- func (p *FsFold) Exists() bool
- func (f *FsFold) FileS(patterns ...*Pattern) (FilS FsFileS)
- func (f *FsFold) HasRecurse() bool
- func (p *FsFold) InfoEquals(oi os.FileInfo) bool
- func (p *FsFold) IsFold() bool
- func (p *FsFold) MkDir() error
- func (p *FsFold) ReadDir() ([]os.FileInfo, error)
- func (f *FsFold) ReadDirS() (entrieS FsInfoS, err error)
- func (f *FsFold) Recurse() bool
- func (p *FsFold) SameFile(oi os.FileInfo) bool
- func (f *FsFold) SubDirS() (DirS []*FsFold)
- func (f *FsFold) TabString() string
- func (p *FsFold) TryFile() (*FsFile, bool)
- func (p *FsFold) TryFold() (*FsFold, bool)
- type FsFoldS
- type FsInfoS
- type FsPathS
- type InfoFriendly
- type MatchFriendly
- type OsFileInfoFriendly
- type PathFriendly
- type PathTypeFriendly
- type Pattern
- func (p *Pattern) Accessible() error
- func (p *Pattern) AsBase() *FsBase
- func (p *Pattern) AsInfo() *fsInfo
- func (p *Pattern) AsPath() *fsPath
- func (p *Pattern) AsPattern() *Pattern
- func (p *Pattern) Base() *FsBase
- func (p *Pattern) BaseLessExt() *FsBase
- func (p *Pattern) BaseMatches(patterns ...*Pattern) (matched bool, err error)
- func (p *Pattern) Exists() (bool, error)
- func (p *Pattern) Ext() *FsBase
- func (p *Pattern) Glob() (matches []string, err error)
- func (p *Pattern) JoinWith(elem ...string) string
- func (p *Pattern) Match(pattern *Pattern) (matched bool, err error)
- func (p *Pattern) MatchDisk() (dirS FsFoldS, filS FsFileS, err error)
- func (p *Pattern) PathMatches(patterns ...*Pattern) (matched bool, err error)
- func (p *Pattern) Split() (dir, file string)
- func (p *Pattern) SplitList() []string
- func (p *Pattern) Stat() (os.FileInfo, error)
- func (p *Pattern) String() string
- func (p *Pattern) TryBase() (*FsBase, bool)
- func (p *Pattern) TryInfo() (*fsInfo, error)
- func (p *Pattern) TryPath() (*fsPath, bool)
- func (p *Pattern) TryPattern() (*Pattern, bool)
- type PatternFriendly
- type PatternS
Constants ¶
const ( // MatchAny matches any sequence of non-Separator characters MatchAny = `*` // MatchOne matches any single non-Separator character MatchOne = `?` // Dot is the extension separator - a period. Dot = `.` )
const ( // ListSep is the os.PathListSeparator ListSep = os.PathListSeparator )
const (
// Tab is the horizontal tabulation character/rune
Tab = "\t"
)
Variables ¶
var Perm os.FileMode = 0644 // default os.FileMode
Perm defaults to '0644' as os.FileMode
Functions ¶
Types ¶
type BaseFriendly ¶
type BaseFriendly interface { PathFriendly }
BaseFriendly summarises methods of type FsBase
Note: this interface is exposed not only for godoc ;-)
type DataFriendly ¶
type DataFriendly interface { InfoFriendly ByteS() []byte Data() string }
DataFriendly summarises methods of type FsData
Note: this interface is exposed not only for godoc ;-)
type DiskFriendly ¶
type DiskFriendly interface { Glob() (matches []string, err error) MatchDisk() (dirS FsFoldS, filS FsFileS, err error) }
DiskFriendly summarises methods related to "what's on the disk" reality checks
Note: this interface is exposed not only for godoc ;-)
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors is a slice of error
type FileFriendly ¶
type FileFriendly interface { InfoFriendly // File Create/Open Create() (*os.File, error) Open() (*os.File, error) // File Read/Write ReadFile() ([]byte, error) WriteFile(byteS []byte) error }
FileFriendly summarises methods of type FsFile
Note: this interface is exposed not only for godoc ;-)
type FilePathFriendly ¶
type FilePathFriendly interface { String() string Base() *FsBase Ext() *FsBase BaseLessExt() *FsBase Split() (dir, file string) SplitList() []string JoinWith(elem ...string) string }
FilePathFriendly summarises methods related to file path strings
Note: this interface is exposed not only for godoc ;-)
type FoldFriendly ¶
type FoldFriendly interface { InfoFriendly MkDir() error ReadDir() ([]os.FileInfo, error) Recurse() bool HasRecurse() bool TabString() string FileS(patterns ...*Pattern) (FilS FsFileS) ReadDirS() (entrieS FsInfoS, err error) SubDirS() (DirS []*FsFold) }
FoldFriendly summarises methods of type FsFold
Note: this interface is exposed not only for godoc ;-)
type FsBase ¶
type FsBase struct {
// contains filtered or unexported fields
}
FsBase represents a basename of the file system.
Note: FsBase is immutable, and as such safe for concurrent use.
func BaseLessExt ¶
BaseLessExt returns name.Base() less name.Ext() as *FsBase
func (*FsBase) Accessible ¶
func (p *FsBase) Accessible() error
Accessible - returns nil, or the error received from os.Open (or Close)
func (*FsBase) AsBase ¶
func (p *FsBase) AsBase() *FsBase
AsBase returns a fresh FsBase for the given FsInfo, or panics, if path is not identical to it's own Base(name).
func (*FsBase) AsInfo ¶
func (p *FsBase) AsInfo() *fsInfo
AsInfo returns a fresh FsInfo, and the error received from os.Stat() (if any), or panics, if TryInfo returns an error (from os.Stat()).
func (*FsBase) AsPath ¶
func (p *FsBase) AsPath() *fsPath
AsPath returns (a pointer to) the underlying fsPath or panics, if TryPath detected some invlaid content.
Note: AsPath exists only for symmetry with respect to the other, higher types.
func (*FsBase) AsPattern ¶
func (p *FsBase) AsPattern() *Pattern
AsPattern returns a fresh Pattern for the given fsPath, or panics, if TryPattern returns an error (ErrBadPattern).
func (*FsBase) Base ¶
func (p *FsBase) Base() *FsBase
Base returns the last element of path. Trailing path separators are removed before extracting the last element. If the path is empty, Base returns ".". If the path consists entirely of separators, Base returns a single separator.
func (*FsBase) BaseLessExt ¶
func (p *FsBase) BaseLessExt() *FsBase
BaseLessExt: name.Base() less name.Ext()
func (*FsBase) BaseMatches ¶
BaseMatches reports whether base name of fsPath matches any of the patterns.
func (*FsBase) Exists ¶
Exists returns whether the given file or directory exists or not from http://stackoverflow.com/a/10510783
func (*FsBase) Ext ¶
func (p *FsBase) Ext() *FsBase
Ext returns the file name extension used by path. The extension is the suffix beginning at the final dot in the final element of path; it is empty if there is no dot.
func (*FsBase) Glob ¶
Glob returns the names of all files matching the pattern (=PathText()), or nil if there is no matching entry(file/directory).
Note. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').
Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.
Note: If fsPath does not exist, Glob may return matches, if fsPath represents a pattern. If fsPath exists, Glob should return exactly one match: itself (unless Ospwd has changed).
func (*FsBase) JoinWith ¶
JoinWith joins f with any number of path elements into a single path, adding a Separator if necessary. Join calls Clean on the result; in particular, all empty strings are ignored. On Windows, the result is a UNC path if and only if the first path element is a UNC path.
func (*FsBase) PathMatches ¶
PathMatches reports whether fsPath matches any of the patterns.
func (*FsBase) Split ¶
func (p *FsBase) Split() (dir, file string)
Split splits path immediately following the final Separator, separating it into a directory and file name component. If there is no Separator in path, Split returns an empty dir and file set to path. The returned values have the property that path = dir+file.
func (*FsBase) SplitList ¶
func (p *FsBase) SplitList() []string
SplitList splits a list of paths joined by the OS-specific ListSeparator, usually found in PATH or GOPATH environment variables. Unlike strings.Split, SplitList returns an empty slice when passed an empty string.
func (*FsBase) Stat ¶
Stat - returns the actual os.Stat() and the error received from os.Stat (of type *PathError)
Note: Stat does not refer to the FileInfo originally embedded into fsPath and thus may return different FileInfo, if content of file system representetd by fsPath has changed.
func (*FsBase) String ¶
func (p *FsBase) String() string
String returns the pathtext repreented by fsPath
func (*FsBase) TryBase ¶
TryBase returns a fresh FsBase for the given path, or false iff path is not identical to it's own Base(name).
func (*FsBase) TryInfo ¶
func (p *FsBase) TryInfo() (*fsInfo, error)
TryInfo returns a fresh fsInfo, and the error received from os.Stat() (if any)
func (*FsBase) TryPath ¶
func (p *FsBase) TryPath() (*fsPath, bool)
TryPath returns (a pointer to) the underlying fsPath false, iff fsPath contains
- any filepath.ListSeparator (= os.PathListSeparator) or
- any of the Match-Metacharacters (MatchAny "*" or MatchOne "?") Note: Match-Metacharacters "[" and "]" are intentionally permitted; they may be used not only in patterns, but also as valid name of some file or folder/directory.
func (*FsBase) TryPattern ¶
TryPattern returns a fresh Pattern for the given path, and false iff ErrBadPattern is returned from Match.
type FsBaseS ¶
type FsBaseS []*FsBase
FsBaseS represents a collection (slice) of (pointers to) FsBase's.
type FsData ¶
type FsData struct { FsFile // contains filtered or unexported fields }
FsData represents the data (as read upon it's creation) of a related FsFile and is intended to be used by higher packages such as FsCache.
Note: FsData is immutable, and as such safe for concurrent use.
func (*FsData) AsFile ¶
func (p *FsData) AsFile() *FsFile
AsFile returns a fresh FsFile for the given FsInfo, or panics, if the FsInfo represents a Dir.
func (*FsData) AsFold ¶
func (p *FsData) AsFold() *FsFold
AsFold returns a fresh FsFold for the given FsInfo, or panics, if the FsInfo does not represent a Dir.
func (*FsData) AsNotDown ¶
func (p *FsData) AsNotDown() *FsFold
AsNotDown returns a fresh FsFold representing a file system directory/file not to be recursed into.
func (*FsData) AsRecurse ¶
func (p *FsData) AsRecurse() *FsFold
AsRecurse returns a fresh FsFold representing a file system directory/file to be recursed into.
func (*FsData) Exists ¶
func (p *FsData) Exists() bool
Exists returns true, if OsPath is known to represent a real disk element which already exists on disk
func (*FsData) InfoEquals ¶
InfoEquals returns true, if all FileInfo data is same.
func (*FsData) IsFold ¶
func (p *FsData) IsFold() bool
IsFold returns IsDir, if it is known to exist, and false otherwise.
func (*FsData) SameFile ¶
SameFile reports whether f and oi describe the same file. For example, on Unix this means that the device and inode fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SameFile only applies to results returned by os.Stat. SameFile returns false in other cases.
type FsDataS ¶
type FsDataS []*FsData
FsDataS represents a collection (slice) of (pointers to) FsData's.
type FsFile ¶
type FsFile struct {
// contains filtered or unexported fields
}
FsFile represents a file of the file system.
Note: FsFile is immutable, and as such safe for concurrent use.
func (*FsFile) AsData ¶
AsData returns a fresh FsData for the given FsFile, or panics, if TryData returns an error (from ReadFile).
func (*FsFile) AsFile ¶
func (p *FsFile) AsFile() *FsFile
AsFile returns a fresh FsFile for the given FsInfo, or panics, if the FsInfo represents a Dir.
func (*FsFile) AsFold ¶
func (p *FsFile) AsFold() *FsFold
AsFold returns a fresh FsFold for the given FsInfo, or panics, if the FsInfo does not represent a Dir.
func (*FsFile) AsNotDown ¶
func (p *FsFile) AsNotDown() *FsFold
AsNotDown returns a fresh FsFold representing a file system directory/file not to be recursed into.
func (*FsFile) AsRecurse ¶
func (p *FsFile) AsRecurse() *FsFold
AsRecurse returns a fresh FsFold representing a file system directory/file to be recursed into.
func (*FsFile) Create ¶
Create creates the file named by OsPath.Path() with mode 0666 (before umask), truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.
Note: do not forget to defer file.Close()
func (*FsFile) Exists ¶
func (p *FsFile) Exists() bool
Exists returns true, if OsPath is known to represent a real disk element which already exists on disk
func (*FsFile) InfoEquals ¶
InfoEquals returns true, if all FileInfo data is same.
func (*FsFile) IsFold ¶
func (p *FsFile) IsFold() bool
IsFold returns IsDir, if it is known to exist, and false otherwise.
func (*FsFile) Open ¶
Open opens the file named by OsPath.Path() for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.
Note: do not forget to defer file.Close()
func (*FsFile) ReadFile ¶
ReadFile reads the file named by OsPath.Path() and returns the contents.
Note: A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported. Note: for convenience, the contents is returned as string, not as []byte.
func (*FsFile) SameFile ¶
SameFile reports whether f and oi describe the same file. For example, on Unix this means that the device and inode fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SameFile only applies to results returned by os.Stat. SameFile returns false in other cases.
func (*FsFile) TryData ¶
TryData returns a fresh FsData for the given FsFile, or false (and empty byteS/data) iff ReadFile() returned an error.
type FsFileS ¶
type FsFileS []*FsFile
FsFileS represents a collection (slice) of (pointers to) FsFile's.
func MatchFiles ¶
MatchFiles matches pathName against the Disk (via MatchDisk/Glob) and then returns only those files the base name of which matches any of the given patternlists. Any eventual filesystem errors are ignored and skipped over.
type FsFold ¶
type FsFold struct {
// contains filtered or unexported fields
}
FsFold represents a folder / directory of the file system. It may indicate to be (or have been) recursed into.
Note: FsFold is immutable, and as such safe for concurrent use.
func NotDown ¶
NotDown returns a fresh FsFold given a pathname, which also indicates not to be recursed into.
func Recurse ¶
Recurse returns a fresh FsFold given a pathname, which also indicates to be recursed.
func (*FsFold) AsFile ¶
func (p *FsFold) AsFile() *FsFile
AsFile returns a fresh FsFile for the given FsInfo, or panics, if the FsInfo represents a Dir.
func (*FsFold) AsFold ¶
func (p *FsFold) AsFold() *FsFold
AsFold returns a fresh FsFold for the given FsInfo, or panics, if the FsInfo does not represent a Dir.
func (*FsFold) AsNotDown ¶
func (p *FsFold) AsNotDown() *FsFold
AsNotDown returns a fresh FsFold representing a file system directory/file not to be recursed into.
func (*FsFold) AsRecurse ¶
func (p *FsFold) AsRecurse() *FsFold
AsRecurse returns a fresh FsFold representing a file system directory/file to be recursed into.
func (*FsFold) Exists ¶
func (p *FsFold) Exists() bool
Exists returns true, if OsPath is known to represent a real disk element which already exists on disk
func (*FsFold) FileS ¶
FileS returns all files in f matching any of the patterns in the patternlists
func (*FsFold) HasRecurse ¶
HasRecurse returns true if this folder has a recurse indicator
func (*FsFold) InfoEquals ¶
InfoEquals returns true, if all FileInfo data is same.
func (*FsFold) IsFold ¶
func (p *FsFold) IsFold() bool
IsFold returns IsDir, if it is known to exist, and false otherwise.
func (*FsFold) MkDir ¶
MkDir uses os.MkdirAll to create a directory named by fsPath, along with any necessary parents, and returns nil, or else returns an error. The permission bits Perm are used for all created directories. If fsPath is already a directory, MkDir does nothing and returns nil.
func (*FsFold) ReadDir ¶
ReadDir reads the directory named by OsPath.Path() and returns a list of directory entries sorted by filename.
func (*FsFold) ReadDirS ¶
ReadDirS reads the directory named by OsPath.Path() and returns a FsInfo slice of directory entries sorted by filename.
func (*FsFold) SameFile ¶
SameFile reports whether f and oi describe the same file. For example, on Unix this means that the device and inode fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SameFile only applies to results returned by os.Stat. SameFile returns false in other cases.
func (*FsFold) SubDirS ¶
SubDirS returns fi and all it's (recursed) subdirectories, the directory tree rooted at fi, so to say.
func (*FsFold) TabString ¶
TabString returns the Name and the Recurse flag as a Tab terminated string
type FsFoldS ¶
type FsFoldS []*FsFold
FsFoldS represents a collection (slice) of (pointers to) FsFold's.
func MatchFolds ¶
MatchFolds matches pathName against the Disk (via MatchDisk/Glob) and then returns only those folders/directories the base name of which matches any of the given patternlists. Any eventual filesystem errors are ignored and skipped over.
type FsInfoS ¶
type FsInfoS []*fsInfo
FsInfoS represents a collection (slice) of (pointers to) FsInfo's.
type FsPathS ¶
type FsPathS []*fsPath
FsPathS represents a collection (slice) of (pointers to) fsPathes
func (FsPathS) Accessible ¶
Accessible returns any errors encountered when accessing it's elements
type InfoFriendly ¶
type InfoFriendly interface { PathFriendly AsFile() *FsFile TryFile() (*FsFile, bool) AsFold() *FsFold TryFold() (*FsFold, bool) AsNotDown() *FsFold AsRecurse() *FsFold Exists() bool IsFold() bool SameFile(oi os.FileInfo) bool InfoEquals(oi os.FileInfo) bool }
InfoFriendly summarises many methods inherited from internal type fsInfo in related groups / sub interfaces
Note: this interface is exposed not only for godoc ;-)
type MatchFriendly ¶
type MatchFriendly interface { DiskFriendly Match(pattern *Pattern) (matched bool, err error) PathMatches(patterns ...*Pattern) (matched bool, err error) BaseMatches(patterns ...*Pattern) (matched bool, err error) }
MatchFriendly summarises methods related to matching
Note: this interface is exposed not only for godoc ;-)
type OsFileInfoFriendly ¶
OsFileInfoFriendly summarises methods related to os.FileInfo
Note: this interface is exposed not only for godoc ;-)
type PathFriendly ¶
type PathFriendly interface { FilePathFriendly MatchFriendly OsFileInfoFriendly PathTypeFriendly Accessible() error }
PathFriendly summarises many methods inherited from internal type fsPath in related groups / sub interfaces
Note: this interface is exposed not only for godoc ;-)
type PathTypeFriendly ¶
type PathTypeFriendly interface { AsPath() *fsPath TryPath() (*fsPath, bool) AsInfo() *fsInfo TryInfo() (*fsInfo, error) AsBase() *FsBase TryBase() (*FsBase, bool) AsPattern() *Pattern TryPattern() (*Pattern, bool) }
PathTypeFriendly summarises methods related to pathes
Note: this interface is exposed not only for godoc ;-)
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern represents a file system pattern
Note: Pattern is immutable, and as such safe for concurrent use.
func ForcePattern ¶
ForcePattern returns a fresh Pattern representing the given a name.
func (*Pattern) Accessible ¶
func (p *Pattern) Accessible() error
Accessible - returns nil, or the error received from os.Open (or Close)
func (*Pattern) AsBase ¶
func (p *Pattern) AsBase() *FsBase
AsBase returns a fresh FsBase for the given FsInfo, or panics, if path is not identical to it's own Base(name).
func (*Pattern) AsInfo ¶
func (p *Pattern) AsInfo() *fsInfo
AsInfo returns a fresh FsInfo, and the error received from os.Stat() (if any), or panics, if TryInfo returns an error (from os.Stat()).
func (*Pattern) AsPath ¶
func (p *Pattern) AsPath() *fsPath
AsPath returns (a pointer to) the underlying fsPath or panics, if TryPath detected some invlaid content.
Note: AsPath exists only for symmetry with respect to the other, higher types.
func (*Pattern) AsPattern ¶
func (p *Pattern) AsPattern() *Pattern
AsPattern returns a fresh Pattern for the given fsPath, or panics, if TryPattern returns an error (ErrBadPattern).
func (*Pattern) Base ¶
func (p *Pattern) Base() *FsBase
Base returns the last element of path. Trailing path separators are removed before extracting the last element. If the path is empty, Base returns ".". If the path consists entirely of separators, Base returns a single separator.
func (*Pattern) BaseLessExt ¶
func (p *Pattern) BaseLessExt() *FsBase
BaseLessExt: name.Base() less name.Ext()
func (*Pattern) BaseMatches ¶
BaseMatches reports whether base name of fsPath matches any of the patterns.
func (*Pattern) Exists ¶
Exists returns whether the given file or directory exists or not from http://stackoverflow.com/a/10510783
func (*Pattern) Ext ¶
func (p *Pattern) Ext() *FsBase
Ext returns the file name extension used by path. The extension is the suffix beginning at the final dot in the final element of path; it is empty if there is no dot.
func (*Pattern) Glob ¶
Glob returns the names of all files matching the pattern (=PathText()), or nil if there is no matching entry(file/directory).
Note. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').
Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.
Note: If fsPath does not exist, Glob may return matches, if fsPath represents a pattern. If fsPath exists, Glob should return exactly one match: itself (unless Ospwd has changed).
func (*Pattern) JoinWith ¶
JoinWith joins f with any number of path elements into a single path, adding a Separator if necessary. Join calls Clean on the result; in particular, all empty strings are ignored. On Windows, the result is a UNC path if and only if the first path element is a UNC path.
func (*Pattern) PathMatches ¶
PathMatches reports whether fsPath matches any of the patterns.
func (*Pattern) Split ¶
func (p *Pattern) Split() (dir, file string)
Split splits path immediately following the final Separator, separating it into a directory and file name component. If there is no Separator in path, Split returns an empty dir and file set to path. The returned values have the property that path = dir+file.
func (*Pattern) SplitList ¶
func (p *Pattern) SplitList() []string
SplitList splits a list of paths joined by the OS-specific ListSeparator, usually found in PATH or GOPATH environment variables. Unlike strings.Split, SplitList returns an empty slice when passed an empty string.
func (*Pattern) Stat ¶
Stat - returns the actual os.Stat() and the error received from os.Stat (of type *PathError)
Note: Stat does not refer to the FileInfo originally embedded into fsPath and thus may return different FileInfo, if content of file system representetd by fsPath has changed.
func (*Pattern) String ¶
func (p *Pattern) String() string
String returns the pathtext repreented by fsPath
func (*Pattern) TryBase ¶
TryBase returns a fresh FsBase for the given path, or false iff path is not identical to it's own Base(name).
func (*Pattern) TryInfo ¶
func (p *Pattern) TryInfo() (*fsInfo, error)
TryInfo returns a fresh fsInfo, and the error received from os.Stat() (if any)
func (*Pattern) TryPath ¶
func (p *Pattern) TryPath() (*fsPath, bool)
TryPath returns (a pointer to) the underlying fsPath false, iff fsPath contains
- any filepath.ListSeparator (= os.PathListSeparator) or
- any of the Match-Metacharacters (MatchAny "*" or MatchOne "?") Note: Match-Metacharacters "[" and "]" are intentionally permitted; they may be used not only in patterns, but also as valid name of some file or folder/directory.
func (*Pattern) TryPattern ¶
TryPattern returns a fresh Pattern for the given path, and false iff ErrBadPattern is returned from Match.
type PatternFriendly ¶
type PatternFriendly interface { PathFriendly }
PatternFriendly summarises methods of type Pattern
Note: this interface is exposed not only for godoc ;-)
type PatternS ¶
type PatternS []*Pattern
PatternS represents a collection (slice) of (pointers to) Pattern's.
func NewPatternS ¶
NewPatternS returns a non-empty slice of Patterns obtained via filepath.SplitList