ulloc

package
v1.64.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: AGPL-3.0 Imports: 4 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanPath

func CleanPath(path string) string

CleanPath is used to normalize all the filepath separators, remove any .. or . components, and keep the trailing slash if necessary.

Types

type Location

type Location struct {
	// contains filtered or unexported fields
}

Location represets a local path, a remote object, or stdin/stdout.

func NewLocal

func NewLocal(path string) Location

NewLocal returns a new Location that refers to a local path.

func NewRemote

func NewRemote(bucket, key string) Location

NewRemote returns a new location that refers to a remote path.

func NewStd

func NewStd() Location

NewStd returns a new location that refers to stdin or stdout.

func Parse

func Parse(location string) (p Location, err error)

Parse turns the string form of the location into the structured Location value and an error if it is unable to or the location is invalid.

func (Location) AppendKey

func (p Location) AppendKey(key string) Location

AppendKey adds the key to the end of the existing key, separating with the appropriate slash if necessary.

func (Location) AsDirectoryish

func (p Location) AsDirectoryish() Location

AsDirectoryish appends a trailing slash to the location if it is not already directoryish.

func (Location) Base

func (p Location) Base() (string, bool)

Base returns the last base component of the key or path not including the last slash.

func (Location) Directoryish

func (p Location) Directoryish() bool

Directoryish returns if the location is syntatically directoryish, meaning that the location component is either empty or ends with a slash.

func (Location) HasPrefix

func (p Location) HasPrefix(pre Location) bool

HasPrefix returns true if the passed in Location is a prefix.

func (Location) Less

func (p Location) Less(q Location) bool

Less returns true if the location is less than the passed in location.

func (Location) ListKeyName

func (p Location) ListKeyName(prefix Location) (string, bool)

ListKeyName returns the full first component of the key after the provided prefix and a boolean indicating if the component is itself a prefix.

func (Location) Loc

func (p Location) Loc() string

Loc returns either the key or path associated with the location.

func (Location) Local

func (p Location) Local() bool

Local returns true if the location is local.

func (Location) LocalParts

func (p Location) LocalParts() (path string, ok bool)

LocalParts returns the path for the location and a bool indicating if that value is valid because the location is local.

func (Location) Parent

func (p Location) Parent() string

Parent returns the section of the key or path up to and including the final slash.

func (Location) RelativeTo

func (p Location) RelativeTo(target Location) (string, error)

RelativeTo returns the string that when appended to the location string will return a string equivalent to the passed in target location.

func (Location) Remote

func (p Location) Remote() bool

Remote returns true if the location is remote.

func (Location) RemoteParts

func (p Location) RemoteParts() (bucket, key string, ok bool)

RemoteParts returns the bucket and key for the location and a bool indicating if those values are valid because the location is remote.

func (Location) RemovePrefix

func (p Location) RemovePrefix(prefix Location) Location

RemovePrefix removes the prefix from the key or path in the location if they begin with it.

func (Location) Std

func (p Location) Std() bool

Std returns true if the location refers to stdin/stdout.

func (Location) String

func (p Location) String() string

String returns the string form of the location.

func (Location) Undirectoryish

func (p Location) Undirectoryish() Location

Undirectoryish removes any trailing slashes from the location.

Jump to

Keyboard shortcuts

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