utils

package
v5.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrBadAbsFilePath constant is returned when a file path is not absolute
	ErrBadAbsFilePath = "absolute file path is invalid - must include leading slash and may not include trailing slash"
	// ErrBadRelFilePath constant is returned when a file path is not relative
	ErrBadRelFilePath = "relative file path is invalid - may not include leading or trailing slashes"
	// ErrBadAbsLocationPath constant is returned when a file path is not absolute
	ErrBadAbsLocationPath = "absolute location path is invalid - must include leading and trailing slashes"
	// ErrBadRelLocationPath constant is returned when a file path is not relative
	ErrBadRelLocationPath = "relative location path is invalid - may not include leading slash but must include trailing slash"
	// TouchCopyMinBufferSize min buffer size used in TouchCopyBuffered in bytes
	TouchCopyMinBufferSize = 262144
)

Variables

This section is empty.

Functions

func EnsureLeadingSlash

func EnsureLeadingSlash(dir string) string

EnsureLeadingSlash is like EnsureTrailingSlash except that it adds the leading slash if needed.

func EnsureTrailingSlash

func EnsureTrailingSlash(dir string) string

EnsureTrailingSlash is like AddTrailingSlash but will only ever use / since it's use for web uri's, never an Windows OS path.

func GetFileURI

func GetFileURI(f vfs.File) string

GetFileURI returns a File URI

func GetLocationURI

func GetLocationURI(l vfs.Location) string

GetLocationURI returns a Location URI

func RemoveLeadingSlash

func RemoveLeadingSlash(path string) string

RemoveLeadingSlash removes leading slash, if any

func RemoveTrailingSlash

func RemoveTrailingSlash(path string) string

RemoveTrailingSlash removes trailing slash, if any

func TouchCopy deprecated

func TouchCopy(writer io.Writer, reader io.Reader) error

Deprecated: Use TouchCopyBuffer Instead TouchCopy is a wrapper around io.Copy which ensures that even empty source files (reader) will get written as an empty file. It guarantees a Write() call on the target file.

func TouchCopyBuffered added in v5.8.0

func TouchCopyBuffered(writer io.Writer, reader io.Reader, bufferSize int) error

TouchCopyBuffered is a wrapper around io.CopyBuffer which ensures that even empty source files (reader) will get written as an empty file. It guarantees a Write() call on the target file. bufferSize is in bytes and if is less than TouchCopyMinBufferSize will result in a buffer of size TouchCopyMinBufferSize bytes. If bufferSize is > TouchCopyMinBufferSize it will result in a buffer of size bufferSize bytes

func UpdateLastModifiedByMoving

func UpdateLastModifiedByMoving(file vfs.File) error

UpdateLastModifiedByMoving is used by some backends' Touch() method when a file already exists.

func ValidateAbsoluteFilePath

func ValidateAbsoluteFilePath(name string) error

ValidateAbsoluteFilePath ensures that a file path has a leading slash but not a trailing slash

func ValidateAbsoluteLocationPath

func ValidateAbsoluteLocationPath(name string) error

ValidateAbsoluteLocationPath ensure that a file path has both leading and trailing slashes

func ValidateRelativeFilePath

func ValidateRelativeFilePath(name string) error

ValidateRelativeFilePath ensures that a file path has neither leading nor trailing slashes

func ValidateRelativeLocationPath

func ValidateRelativeLocationPath(name string) error

ValidateRelativeLocationPath ensure that a file path has no leading slash but has a trailing slash

Types

type Authority added in v5.5.0

type Authority struct {
	User, Pass, Host string
	// contains filtered or unexported fields
}

Authority represents host, port and userinfo (user/pass) in a URI

func NewAuthority added in v5.5.0

func NewAuthority(authority string) (Authority, error)

NewAuthority initializes Authority struct by parsing authority string.

func (Authority) String added in v5.5.0

func (a Authority) String() string

String() returns a string representation of authority. It does not include password per https://tools.ietf.org/html/rfc3986#section-3.2.1:

Applications should not render as clear text any data after the first colon (":") character found within a userinfo
subcomponent unless the data after the colon is the empty string (indicating no password).

Jump to

Keyboard shortcuts

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