utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxCopy added in v0.5.0

func CtxCopy(ctx context.Context, dst io.Writer, src io.Reader) (written int64, err error)

func CtxCopyN added in v0.5.0

func CtxCopyN(ctx context.Context, dst io.Writer, src io.Reader, n int64) (written int64, err error)

func EnsureFolder

func EnsureFolder(path string) error

EnsureFolder creates a folder if it doesn't exist already

func IsIgnoredFile added in v0.2.1

func IsIgnoredFile(file string) bool

IsIgnoredFile returns true if the file should be ignored and not added to the repository Ignored files include OS metadata files etc

func IsRegularFile

func IsRegularFile(path string) (bool, error)

IsRegularFile returns true if the path is a file

func PathExists

func PathExists(path string) (bool, error)

PathExists returns true if the path exists on disk

func SanitizeMimeType added in v0.3.0

func SanitizeMimeType(mime string) string

SanitizeMimeType sanitizes a mime type

func SanitizePath added in v0.2.0

func SanitizePath(path string) string

SanitizePath removes certain problematic characters from path names

Types

type CtxReader added in v0.5.0

type CtxReader func(p []byte) (n int, err error)

func ReaderFuncWithContext added in v0.4.1

func ReaderFuncWithContext(ctx context.Context, r io.Reader) CtxReader

ReaderFuncWithContext returns a stream reader that supports a context

func (CtxReader) Read added in v0.5.0

func (rf CtxReader) Read(p []byte) (n int, err error)

type CtxWriter added in v0.5.0

type CtxWriter func(p []byte) (n int, err error)

func (CtxWriter) Write added in v0.5.0

func (rf CtxWriter) Write(p []byte) (n int, err error)

type HttpRange added in v0.5.0

type HttpRange struct {
	Start, Length int64
}

HttpRange specifies the byte range to be sent to the client.

func ParseRange added in v0.5.0

func ParseRange(s string) (*HttpRange, error)

ParseRange parses a Range header string as per a subset of RFC 7233 This supports two formats only: `bytes=startByte-` and `bytes=startByte-endByte` (that's the least common denominator supported by all services)

Jump to

Keyboard shortcuts

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