fastpath

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 1 Imported by: 3

README

Alternative path library with a strings.Builder like path builder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(path string) string

Clean: see Builder.Clean(). Analogous to path.Clean().

func Join

func Join(elems ...string) string

Join: see Builder.Join(). Analogous to path.Join().

Types

type Builder

type Builder struct {
	// B is the underlying byte buffer
	B []byte
	// contains filtered or unexported fields
}

Builder provides a means of cleaning and joining system paths, while retaining a singular underlying byte buffer for performance.

func (Builder) Absolute

func (b Builder) Absolute() bool

Absolute returns whether current path is absolute (not relative).

func (*Builder) Append

func (b *Builder) Append(path string)

Append adds and cleans the supplied path string to the builder's internal buffer, growing the buffer if necessary to accomodate the extra path length.

func (*Builder) AppendBytes

func (b *Builder) AppendBytes(path []byte)

AppendBytes adds and cleans the supplied path bytes to the builder's internal buffer, growing the buffer if necessary to accomodate the extra path length.

func (Builder) Bytes

func (b Builder) Bytes() []byte

Bytes returns the accumulated path bytes.

func (Builder) Cap

func (b Builder) Cap() int

Cap returns the capacity of the underlying Builder buffer

func (*Builder) Clean

func (b *Builder) Clean(path string) string

Clean creates the shortest possible functional equivalent to the supplied path, resetting the builder before performing this operation. The builder object is NOT reset after return.

func (*Builder) Guarantee

func (b *Builder) Guarantee(size int)

Guarantee ensures there is at least the requested size free bytes available in the buffer, reallocating if necessary

func (*Builder) Join

func (b *Builder) Join(elems ...string) string

Join connects and cleans multiple paths, resetting the builder before performing this operation and returning the shortest possible combination of all the supplied paths. The builder object is NOT reset after return.

func (Builder) Len

func (b Builder) Len() int

Len returns the number of accumulated bytes in the Builder

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the Builder object

func (*Builder) SetAbsolute

func (b *Builder) SetAbsolute(enabled bool)

SetAbsolute converts the current path to-or-from absolute.

func (Builder) String

func (b Builder) String() string

String returns the accumulated path string.

func (*Builder) Truncate

func (b *Builder) Truncate(size int)

Truncate reduces the length of the buffer by the requested number of bytes. If the byte slice is *effectively* empty, i.e. absolute and "/" or relative and ".", it won't be truncated.

Jump to

Keyboard shortcuts

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