utils

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentLengthKey          = contextKey("contentLength")
	RangeKey                  = contextKey("rangeKey")
	IsCopy                    = contextKey("isCopy")
	Origin                    = contextKey("origin")
	ShowCorrupted             = contextKey("showCorrupted")
	ActiveStreamKey           = contextKey("activeStream")
	StreamIDKey               = contextKey("streamID")
	StreamSourceKey           = contextKey("streamSource")
	StreamUserNameKey         = contextKey("streamUserName")
	ClientIPKey               = contextKey("clientIP")
	UserAgentKey              = contextKey("userAgent")
	MaxPrefetchKey            = contextKey("maxPrefetch")
	SuppressStreamTrackingKey = contextKey("suppressStreamTracking")
)

Context keys for passing WebDAV request metadata through context

Variables

This section is empty.

Functions

func CheckDirectoryWritable added in v0.3.0

func CheckDirectoryWritable(path string) error

CheckDirectoryWritable checks if a directory exists and is writable. If the directory doesn't exist, it attempts to create it.

func CheckFileDirectoryWritable added in v0.3.0

func CheckFileDirectoryWritable(filePath string, fileType string) error

CheckFileDirectoryWritable checks if the directory containing a file path is writable.

func JoinAbsPath added in v0.3.0

func JoinAbsPath(basePath, otherPath string) string

JoinAbsPath safely joins a base path with another path (which could be absolute or relative). If the second path is absolute and starts with the base path, it returns the second path as is. Otherwise, it joins them normally.

func MoveFile added in v0.3.0

func MoveFile(src, dst string) error

MoveFile atomically renames a file from src to dst. If the rename fails due to cross-device boundaries, it falls back to a robust copy-and-delete.

func RemoveEmptyDirs added in v0.3.0

func RemoveEmptyDirs(root, path string)

RemoveEmptyDirs recursively removes empty parent directories starting from 'path' up towards 'root' (exclusive). It stops if it encounters a non-empty directory or reaches the root.

Types

type RangeHeader

type RangeHeader struct {
	Start int64
	End   int64
}

func ParseRangeHeader

func ParseRangeHeader(s string) (po *RangeHeader, err error)

ParseRangeHeader parses a RangeHeader from a Range: header. It only accepts single ranges.

func (*RangeHeader) Decode

func (o *RangeHeader) Decode(size int64) (offset, limit int64)

Decode interprets the RangeOption into an offset and a limit

The offset is the start of the stream and the limit is how many bytes should be read from it. If the limit is -1 then the stream should be read to the end.

Jump to

Keyboard shortcuts

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