paths

package
v0.0.0-...-39e2216 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

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 NewPath

func NewPath(p string) *Path

NewPath creates a new path. If it is a folder, it will end with a trailing '/'

func NewPathDir

func NewPathDir(p string) *Path

NewPathDir will create a Path *always* terminated with a traling '/'. Handy for folders which doesn't exist yet

func (*Path) Abs

func (p *Path) Abs() *Path

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

func (p *Path) Add(s string) *Path

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) AddNoSep

func (p *Path) AddNoSep(s string) *Path

AddNoSep adds a string path to a Path with no triling separator

func (*Path) AddP

func (p *Path) AddP(path *Path) *Path

AddP adds a Path to a Path no check is done regarding the absolute path of the argument

func (*Path) AddPNoSep

func (p *Path) AddPNoSep(path *Path) *Path

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

func (p *Path) Base() string

Base is filepath.Base(): It returns the last element of path. Trailing path separators are removed before extracting the last element.

func (*Path) DeleteFolder

func (dir *Path) DeleteFolder() error

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

func (p *Path) Dir() *Path

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

func (p *Path) Dot() *Path

Dot return a path prefixed with ".\" (dot plus file separator) If it already starts with ./, returns the same path

func (*Path) EndsWithSeparator

func (p *Path) EndsWithSeparator() bool

EndsWithSeparator checks if Paths ends with a filepath separator

func (*Path) Exists

func (p *Path) Exists() bool

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

func (p *Path) FileContent() string

FileContent returns the content of a file, or "" is error. error is on Stderr

func (*Path) GetDateOrderedFiles

func (dir *Path) GetDateOrderedFiles(pattern string) []os.FileInfo

GetDateOrderedFiles returns files of a folder sorted chronologically (most recent to oldest). Not recursive.

func (*Path) GetFiles

func (dir *Path) GetFiles(pattern string) []os.FileInfo

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

func (dir *Path) GetLastModifiedFile(pattern string) string

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

func (dir *Path) GetNameOrderedFiles(pattern string) []os.FileInfo

GetNameOrderedFiles returns files of a folder sorted alphabetically. Not recursive.

func (Path) HasTar

func (p Path) HasTar() bool

HasTar checks if a file and with .tar(.xxx) For example a.tar.gz has tar.

func (*Path) Is7z

func (p *Path) Is7z() bool

Is7z checks if a path ends with .7z For file or folder

func (*Path) IsDir

func (p *Path) IsDir() bool

IsDir checks is a path is an existing directory. If there is any error, it is printed on Stderr, but not returned.

func (*Path) IsEmpty

func (p *Path) IsEmpty() bool

IsEmpty checks if p is nil or has an empty path

func (*Path) IsExe

func (p *Path) IsExe() bool

IsExe checks if a path ends with .exe For file or folder

func (*Path) IsExeOrMsi

func (p *Path) IsExeOrMsi() bool

IsExeOrMsi returns true if Path (file or folder) ends with .exe or .msi

func (*Path) IsGz

func (p *Path) IsGz() bool

IsGz checks if a path ends with .gz For file or folder

func (*Path) IsMsi

func (p *Path) IsMsi() bool

IsMsi checks if a path ends with .exe For file or folder

func (*Path) IsPortableCompressed

func (p *Path) IsPortableCompressed() bool

IsPortableCompressed checks if path is ending with .zip or .tar.gz or .tar.7z

func (*Path) IsTar

func (p *Path) IsTar() bool

IsTar checks if a path ends with .tar For file or folder

func (*Path) IsTar7z

func (p *Path) IsTar7z() bool

IsTar7z checks if a path ends with .tar.7z For file or folder

func (*Path) IsTarGz

func (p *Path) IsTarGz() bool

IsTarGz checks if a path ends with .tar.gz For file or folder

func (*Path) IsZip

func (p *Path) IsZip() bool

IsZip checks if a path ends with .zip For file or folder

func (*Path) IsZipOr7z

func (p *Path) IsZipOr7z() bool

IsZipOr7z returns true if Path (file or folder) ends with .zip or .tar

func (*Path) MkdirAll

func (p *Path) MkdirAll() bool

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

func (p *Path) MustOpenFile(append bool) (file *os.File)

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

func (p *Path) NoExt() *Path

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

func (p *Path) NoSep() *Path

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

func (p *Path) NoSubst() *Path

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

func (p *Path) RemoveExtension() *Path

RemoveExtension removes .tar if path ends with .tar Preserves file separator indicating a folder

func (*Path) SameFileContentAs

func (p *Path) SameFileContentAs(file *Path) bool

SameFileContentAs checks if two files have the same content. Get both file content in memory.

func (*Path) SetDir

func (p *Path) SetDir() *Path

SetDir makes sure a Path represents a folder (existing or not) That means it ends with a path separator

func (*Path) SetExt7z

func (p *Path) SetExt7z() *Path

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

func (p *Path) SetExtGz() *Path

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

func (p *Path) SetExtTar() *Path

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

func (p *Path) String() 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

func (p *Path) Subst() *Path

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

func (p *Path) Uncompress(dest *Path) (res bool)

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

Jump to

Keyboard shortcuts

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