storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDirExists

func EnsureDirExists(path string) error

EnsureDirExists creates a directory if it doesn't exist.

func ResolveDuplicateFilename added in v0.4.0

func ResolveDuplicateFilename(dir, baseName string) string

ResolveDuplicateFilename finds an available filename by appending numbers if the file exists.

func SaveStreamToFile

func SaveStreamToFile(stream io.Reader, filePath string, onProgress func(bytesWritten int64)) error

SaveStreamToFile saves an io.Reader stream to a specified file path. It creates necessary directories. It reports progress via the onProgress callback (bytes written).

func SaveStreamToFileWithMetadata added in v0.2.0

func SaveStreamToFileWithMetadata(stream io.Reader, filePath string, modified *string, accessed *string, onProgress func(bytesWritten int64), logger *zap.SugaredLogger) error

SaveStreamToFileWithMetadata saves an io.Reader stream and restores optional timestamps.

Types

type ProgressWriter

type ProgressWriter struct {
	Writer       io.Writer
	BytesWritten int64
	OnProgress   func(bytesWritten int64)
}

ProgressWriter is a wrapper around io.Writer that calls a callback on Write.

func (*ProgressWriter) Write

func (pw *ProgressWriter) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

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