Documentation ¶
Index ¶
- type Path
- func (p *Path) Abs() *Path
- func (p *Path) Add(s string) *Path
- func (p *Path) AddNoSep(s string) *Path
- func (p *Path) AddP(path *Path) *Path
- func (p *Path) AddPNoSep(path *Path) *Path
- func (p *Path) Base() string
- func (dir *Path) DeleteFolder() error
- func (p *Path) Dir() *Path
- func (p *Path) Dot() *Path
- func (p *Path) EndsWithSeparator() bool
- func (p *Path) Exists() bool
- func (p *Path) FileContent() string
- func (dir *Path) GetDateOrderedFiles(pattern string) []os.FileInfo
- func (dir *Path) GetFiles(pattern string) []os.FileInfo
- func (dir *Path) GetLastModifiedFile(pattern string) string
- func (dir *Path) GetNameOrderedFiles(pattern string) []os.FileInfo
- func (p Path) HasTar() bool
- func (p *Path) Is7z() bool
- func (p *Path) IsDir() bool
- func (p *Path) IsEmpty() bool
- func (p *Path) IsExe() bool
- func (p *Path) IsExeOrMsi() bool
- func (p *Path) IsGz() bool
- func (p *Path) IsMsi() bool
- func (p *Path) IsPortableCompressed() bool
- func (p *Path) IsTar() bool
- func (p *Path) IsTar7z() bool
- func (p *Path) IsTarGz() bool
- func (p *Path) IsZip() bool
- func (p *Path) IsZipOr7z() bool
- func (p *Path) MkdirAll() bool
- func (p *Path) MustOpenFile(append bool) (file *os.File)
- func (p *Path) NoExt() *Path
- func (p *Path) NoSep() *Path
- func (p *Path) NoSubst() *Path
- func (p *Path) RemoveExtension() *Path
- func (p *Path) SameFileContentAs(file *Path) bool
- func (p *Path) SetDir() *Path
- func (p *Path) SetExt7z() *Path
- func (p *Path) SetExtGz() *Path
- func (p *Path) SetExtTar() *Path
- func (p *Path) String() string
- func (p *Path) Subst() *Path
- func (p *Path) Uncompress(dest *Path) (res bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path represents a path always '/' separated. Either filename or http://...
func NewPathDir ¶
NewPathDir will create a Path *always* terminated with a traling '/'. Handy for folders which doesn't exist yet
func (*Path) Abs ¶
Abs returns the absolute path if it can, or nil if error The error is printed on stderr If the path ends with a separator, said separator is preserved
func (*Path) Add ¶
Add adds a string path to a Path Makes sure the current path represents a folder first (existing or not it: just means making sure it ends with file separator)
func (*Path) AddP ¶
AddP adds a Path to a Path no check is done regarding the absolute path of the argument
func (*Path) AddPNoSep ¶
AddPNoSep adds a Path to a Path, making sure the resulting path doesn't end with a file separator no check is done regarding the absolute path of the argument
func (*Path) Base ¶
Base is filepath.Base(): It returns the last element of path. Trailing path separators are removed before extracting the last element.
func (*Path) DeleteFolder ¶
DeleteFolder deletes all content (files and subfolders) of a directory. Then delete the directoriy itself Does nothing if dir is a file. return the error ot the first os.RemoveAll issue
func (*Path) Dir ¶
Dir is filepath.Dir() for Path: It returns all but the last element of path, typically the path's directory Its result still ends with a file separator
func (*Path) Dot ¶
Dot return a path prefixed with ".\" (dot plus file separator) If it already starts with ./, returns the same path
func (*Path) EndsWithSeparator ¶
EndsWithSeparator checks if Paths ends with a filepath separator
func (*Path) Exists ¶
Exists returns whether the given file or directory exists or not http://stackoverflow.com/questions/10510691/how-to-check-whether-a-file-or-directory-denoted-by-a-path-exists-in-golang
func (*Path) FileContent ¶
FileContent returns the content of a file, or "" is error. error is on Stderr
func (*Path) GetDateOrderedFiles ¶
GetDateOrderedFiles returns files of a folder sorted chronologically (most recent to oldest). Not recursive.
func (*Path) GetFiles ¶
GetFiles returns all files and folders within a dir, matching a pattern. If the dir is not an actual existing dir, returns an empty list. Empty pattern means all files and subfolders are returned. This is not recursive.
func (*Path) GetLastModifiedFile ¶
GetLastModifiedFile returns the name of the last modified file in a dir (provided its name match the pattern: no pattern means any file). returns empty string if error or no files.
func (*Path) GetNameOrderedFiles ¶
GetNameOrderedFiles returns files of a folder sorted alphabetically. Not recursive.
func (*Path) IsDir ¶
IsDir checks is a path is an existing directory. If there is any error, it is printed on Stderr, but not returned.
func (*Path) IsExeOrMsi ¶
IsExeOrMsi returns true if Path (file or folder) ends with .exe or .msi
func (*Path) IsPortableCompressed ¶
IsPortableCompressed checks if path is ending with .zip or .tar.gz or .tar.7z
func (*Path) MkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents, and return true if created, false otherwise. Any error is printed on Stderr
func (*Path) MustOpenFile ¶
MustOpenFile create or append a file, or panic if issue. If the Path is a Dir, returns nil. The caller is responsible for closing the file
func (*Path) NoExt ¶
NoExt removes extension (any .xxx.yyy path), for file or folder Preserve the final path separator for folder Returns the same p object if no extension found
func (*Path) NoSep ¶
NoSep makes sure the path doesn't end with a file separator. If it already was not ending with the file separator, it returns the same object. If it was, it returns a new Path.
func (*Path) NoSubst ¶
NoSubst returns the path no using a subst path. If no subst or matching subst, returns the same object. If matching substs, returns new path with long form.
func (*Path) RemoveExtension ¶
RemoveExtension removes .tar if path ends with .tar Preserves file separator indicating a folder
func (*Path) SameFileContentAs ¶
SameFileContentAs checks if two files have the same content. Get both file content in memory.
func (*Path) SetDir ¶
SetDir makes sure a Path represents a folder (existing or not) That means it ends with a path separator
func (*Path) SetExt7z ¶
SetExt7z add a .7z to the path after removing its current extension For file or folder. Don't add .7z if, after removing extension, its ends with .7z For instance a.7z.xxx => a.7z
func (*Path) SetExtGz ¶
SetExtGz add a .gz to the path after removing its current extension For file or folder. Don't add .gz if, after removing extension, its ends with .gz For instance a.gz.xxx => a.gz
func (*Path) SetExtTar ¶
SetExtTar add a .tar to the path after removing its current extension For file or folder. Don't add .tar if, after removing extension, its ends with .tar For instance a.tar.gz => a.tar
func (*Path) String ¶
String display a (possibly abbreviated) string version of a Path. If nil, returns <nil> if too long (>200), display only the first 20 plus its length
func (*Path) Subst ¶
Subst returns the path using a subst path. If no subst ormatching subst, returns the same object. If matching subst, returns new path with the short SUBSTed form.
func (*Path) Uncompress ¶
Uncompress a zip (without needed 7z.exe), or any other archive file (if 7z.exe is installed). False if not a file, or not an archive