pth

package module
v0.0.0-...-880e025 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Unlicense Imports: 8 Imported by: 3

README

pth

Routines useful for handling file/dir paths, an extension of package path. I tried to make it cross-platform as much as I could.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Err_NotExist    = errors.New("File/dir doesn't exist")
	Err_Permission  = errors.New("Permission Denied")
	Err_ReadOnly    = errors.New("Read only file")
	Err_WriteOnly   = errors.New("Write only file")
	Err_RangeError  = errors.New("Range error")
	Err_IllegalFile = errors.New("Illegal file - bad data")
	Err_InvalidData = errors.New("Invalid data")
)

Functions

func AsRealPath

func AsRealPath(l ...string) string

return a real path for the given internal path

can pass a list of strings for joining; e.g. AsRealPath("fred", "barney", "wilma", "betty") and get "fred/barney/wilma/betty" -- with 'fred' allowed to have the meta path tokens above

func ChkFileErr

func ChkFileErr(err error) error

func Exists

func Exists(filePath string) bool

Exists tests if the given path exists.

func Ext

func Ext(srcPath string) string

returns just the file extention of the path (if it contains one)

func Homify

func Homify(p string) string

returns a path with home '~' if it can

func Join

func Join(dir, file, ext string) string

returns a path consisting of the dir/file.ext

func MakePath

func MakePath(path string) error

make a directory path, with all parents as needed

func PathToFilename

func PathToFilename(p string) string

func SetNumberedPath

func SetNumberedPath(n int, path string)

set the numbered meta path for use with 'AsRealPath'

func Split

func Split(src string) (dir, file, ext string)

returns dir, filename & ext for the given srcPath

	e.g. /foo/bar/boo.ext -> "/foo/bar"  "boo"  & ".ext"
NOTE: if there is no .extention, the 'file' may be the last dir in a path

func TimeBasedFilename

func TimeBasedFilename(t time.Time) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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