osutil

package
v0.0.0-...-2e2b10f Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package osutil provides helper functions around package os.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCorrupted

func IsCorrupted(err error) bool

IsCorrupted returns true if the given error has occured during copying. If this is true, then the user must notify the user and discard the reader.

Types

type TempFile

type TempFile struct {
	os.File
}

TempFile is a temporary file.

func Consume

func Consume(r io.Reader) (*TempFile, error)

Consume consumes the given io.Reader and returns a temporary file that will be deleted when it is closed.

func Mktemp

func Mktemp(pattern string) (*TempFile, error)

Mktemp creates a new temp file in a predefined temporary directory. Pattern is optional.

func (*TempFile) Close

func (t *TempFile) Close() error

Close closes the file and removes it.

func (*TempFile) Open

func (t *TempFile) Open() (*os.File, error)

Open opens the current temporary file. The new file will not remove the temporary file when it is closed. This is useful for creating simultaneous readers on the same file.

func (*TempFile) Rewind

func (t *TempFile) Rewind() error

Rewind resets the file reader cursor to the start position. This is a convenient function around Seek.

Jump to

Keyboard shortcuts

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