fspath

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package fspath is similar to the standard path package but provides functions that are more useful for path manipulation in the presence of symbolic links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendClean

func AppendClean(buf []byte, path string) []byte

AppendClean is like cleanPath but it appends the result to the byte slice passed as first argument.

func Clean

func Clean(path string) string

Clean is like path.Clean but it preserves parent directory references; this is necessary to ensure that symbolic links aren't erased from walking the path.

func Depth

func Depth(path string) (depth int)

Depth returns the depth of a path. The root "/" has depth zero.

func HasTrailingSlash

func HasTrailingSlash(s string) bool

func IndexSlash

func IndexSlash(path string) int

IndexSlash is like strings.IndexByte(path, '/') but the function is simple enough to be inlined, which is a measurable improvement since it gets called very often by the other routines in this file.

func IsAbs

func IsAbs(path string) bool

IsAbs returns true if the path is absolute, which means that it starts with a slash ("/").

func IsRoot added in v0.1.1

func IsRoot(path string) bool

IsRoot returns true if the path represents a root directory, which means that it is absolute and composed only of sequences of "/", ".", and "..".

func Join

func Join(dir, name string) string

Join is similar to path.Join but is simplified to only join two paths and avoid cleaning parent directory references in the paths.

func TrimLeadingSlash

func TrimLeadingSlash(s string) string

func TrimTrailingSlash

func TrimTrailingSlash(s string) string

func Walk

func Walk(path string) (elem, name string)

Walk separates the next path element from the rest of the path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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