path

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RxDupeSlashes   = regexp.MustCompile(`/+`)
	RxBothSlashes   = regexp.MustCompile(`^\s*/?(.+?)/?\s*$`)
	RxSlashDotSlash = regexp.MustCompile(`/\./`)
)
View Source
var (
	ErrorDirNotFound = fmt.Errorf(`not found or not an existing directory`)
)

Functions

func Abs

func Abs(path string) (absolute string, err error)

Abs is a convenience wrapper around filepath.Abs

func Base

func Base(path string) (name string)

Base returns the name of the file without the extension

func ChmodAll

func ChmodAll(src string)

func CleanWithSlash

func CleanWithSlash(path string) (clean string)

func CleanWithSlashes

func CleanWithSlashes(path string) (clean string)

func CopyFile

func CopyFile(src, dst string) (int64, error)

func Dir

func Dir(path string) (name string)

Dir is a convenience wrapper around filepath.Dir

func Exists

func Exists(path string) bool

Exists returns true if the path is present on the local filesystem

func Ext

func Ext(path string) (extn string)

Ext returns the extension of the file (without the dot)

func ExtExt

func ExtExt(path string) (extn, extra string)

ExtExt returns the extension of the file (without the dot) and any secondary extension found in the path

func FindAllDirs

func FindAllDirs(path string, includeHidden bool) (dirs []string, err error)

func FindAllFiles

func FindAllFiles(path string, includeHidden bool) (files []string, err error)

func FindFileRelativeToPath

func FindFileRelativeToPath(name, path string) (file string)

func FindFileRelativeToPwd

func FindFileRelativeToPwd(name string) (file string)

func GetSectionSlug

func GetSectionSlug(url string) (path, section, slug string)

func IsDir

func IsDir(path string) bool

IsDir returns true if the path is an existing directory

func IsFile

func IsFile(path string) bool

IsFile returns true if the path is an existing file

func IsHiddenPath

func IsHiddenPath(path string) (hidden bool)

func Join

func Join(parts ...string) (joined string)

func JoinWithSlash

func JoinWithSlash(paths ...string) (joined string)

func JoinWithSlashes

func JoinWithSlashes(paths ...string) (joined string)

func List

func List(path string) (paths []string, err error)

List returns a list of directories and files, sorted in natural order with directories grouped before files

func ListAllDirs

func ListAllDirs(path string) (paths []string, err error)

func ListAllFiles

func ListAllFiles(path string) (paths []string, err error)

func ListDirs

func ListDirs(path string) (paths []string, err error)

func ListFiles

func ListFiles(path string) (paths []string, err error)

func Mime

func Mime(path string) (mime string, err error)

Mime returns the MIME type string of a local file

func MimeFromPathOnly

func MimeFromPathOnly(path string) (mime string)

func Mkdir

func Mkdir(path string) (err error)

func PruneEmptyDirs

func PruneEmptyDirs(path string) (err error)

func Pwd

func Pwd() (path string)

func ReadDir

func ReadDir(path string) (paths []fs.DirEntry, err error)

ReadDir is a convenience wrapper around os.ReadDir

func ReadFile

func ReadFile(path string) (content []byte, err error)

ReadFile is a convenience wrapper around os.ReadFile

func SafeConcatRelPath

func SafeConcatRelPath(root string, paths ...string) (out string)

func SafeConcatUrlPath

func SafeConcatUrlPath(root string, paths ...string) (out string)

func Stat

func Stat(path string) (spec times.Timespec, err error)

Stat is a convenience wrapper around github-com-djherbis-times.Stat

func ToSlug

func ToSlug(path string) (slug string)

func TrimDotSlash

func TrimDotSlash(path string) (out string)

func TrimExt

func TrimExt(path string) (out string)

TrimExt returns the path without any file extension

func TrimPrefix

func TrimPrefix(path, prefix string) (modified string)

func TrimRelativeToRoot

func TrimRelativeToRoot(path, root string) (rel string)

func TrimSlash

func TrimSlash(path string) (clean string)

func TrimSlashes

func TrimSlashes(path string) (clean string)

func TrimTrailingSlash

func TrimTrailingSlash(path string) (out string)

func Walk

func Walk(root string, fn filepath.WalkFunc) (err error)

Walk is a convenience wrapper around filepath.Walk

func Which

func Which(name string) (path string)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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