temp

package
v0.26.10 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 11 Imported by: 16

Documentation

Overview

Package temp contains some temporary file -related functions

Index

Constants

This section is empty.

Variables

View Source
var MaxInMemorySlurp = 4 << 20 // 4MB.  *shrug*.

MaxInMemorySlurp is the threshold for in-memory or on-disk storage for slurped data.

Functions

func BaseName

func BaseName(fileName string) string

BaseName returns the last part of the filename - both POSIX and Windows meaning

func LinkAlreadyExists

func LinkAlreadyExists(err error) bool

LinkAlreadyExists checks the error and returns whether this is about a link already exists or not

func LinkOrCopy

func LinkOrCopy(src, dst string) error

LinkOrCopy links src to dst if possible; fails back to copying

func ReaderToFile

func ReaderToFile(r io.Reader, prefix, suffix string) (filename string, err error)

ReaderToFile copies the reader to a temp file and returns its name or error

Types

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	ReaderAt
	io.Closer
	Stat() (os.FileInfo, error)
}

ReadSeekCloser is an io.Reader + ReaderAt + io.Seeker + io.Closer + Stater

func MakeReadSeekCloser

func MakeReadSeekCloser(blobRef string, r io.Reader) (ReadSeekCloser, error)

MakeReadSeekCloser makes an io.ReadSeeker + io.Closer by reading the whole reader If the given Reader is a Closer, too, than that Close will be called

func NewReadSeeker

func NewReadSeeker(r io.Reader) (ReadSeekCloser, error)

NewReadSeeker is a convenience function of MakeReadSeekCloser.

type ReadWriteSeekCloser

type ReadWriteSeekCloser interface {
	ReadSeekCloser
	io.Writer
}

ReadWriteSeekCloser is an io.Writer + io.Reader + io.Seeker + io.Closer.

func NewMemorySlurper

func NewMemorySlurper(blobRef string) ReadWriteSeekCloser

NewMemorySlurper returns an ReadWriteSeekCloser, with some important constraints: you can Write into it, but whenever you call Read or Seek on it, Write is forbidden, will return an error.

type ReaderAt

type ReaderAt interface {
	ReadAt(p []byte, off int64) (n int, err error)
}

ReaderAt is the interface for ReadAt - read at position, without moving pointer.

type Stater

type Stater interface {
	Stat() (os.FileInfo, error)
}

Stater is the interface for os.Stat.

Jump to

Keyboard shortcuts

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