io

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package io contains generated code by adptool.

Package io provides I/O utility functions, extending the standard io package.

Index

Constants

View Source
const (
	SeekCurrent = io.SeekCurrent
	SeekEnd     = io.SeekEnd
	SeekStart   = io.SeekStart
)

Variables

View Source
var (
	Discard          = io.Discard
	EOF              = io.EOF
	ErrClosedPipe    = io.ErrClosedPipe
	ErrNoProgress    = io.ErrNoProgress
	ErrShortBuffer   = io.ErrShortBuffer
	ErrShortWrite    = io.ErrShortWrite
	ErrUnexpectedEOF = io.ErrUnexpectedEOF
)
View Source
var (
	// ErrZeroSize indicates that a file's size is zero.
	ErrZeroSize = errors.New("file Size is zero")
	// ErrUnsupportedType indicates that a file's type is not supported.
	ErrUnsupportedType = errors.New("file type is not supported")
	// ErrTargetIsNotDir indicates that a target path for an operation is not a directory.
	ErrTargetIsNotDir = errors.New("target is not a directory")
	// ErrRead indicates a failure to read from a file.
	ErrRead = errors.New("file read error")
	// ErrWrite indicates a failure to write to a file.
	ErrWrite = errors.New("file write error")
	// ErrNotExist indicates that a file or directory does not exist.
	ErrNotExist = errors.New("file not exist")
	// ErrEmptyPath indicates that a file path is empty.
	ErrEmptyPath = errors.New("file path is empty")
	// ErrSizeNotMatch indicates that the number of bytes written does not match the expected size.
	ErrSizeNotMatch = errors.New("file size not match")
)

Errors returned by this package.

Functions

func Copy added in v1.1.0

func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error)

Copy copies data from src to dst until EOF, context cancellation, or an error occurs. It returns the number of bytes copied.

func Delete added in v1.1.0

func Delete(path string) error

Delete removes the file at the specified path. If the path is empty, it returns ErrEmptyPath. If the file does not exist, it returns no error.

func Exists added in v1.1.0

func Exists(path string) (bool, error)

Exists checks if a file or directory exists at the given path. It returns true if the path exists, and false if it does not. An error is returned only if the check itself fails due to permission issues or other system errors.

func ReadToBuffer added in v1.1.0

func ReadToBuffer(path string, buf *bytes.Buffer) (int64, error)

ReadToBuffer reads the entire file at the given path into the provided buffer.

func Save added in v1.1.0

func Save(ctx context.Context, dstPath string, src io.Reader) (int64, error)

Save reads all data from a reader and saves it to the specified destination path. It automatically creates any necessary parent directories for the destination path.

func StdCopy

func StdCopy(dst io.Writer, src io.Reader) (written int64, err error)

func StdCopyBuffer

func StdCopyBuffer(dst io.Writer, src io.Reader, buf []byte) (written int64, err error)

func StdCopyN

func StdCopyN(dst io.Writer, src io.Reader, n int64) (written int64, err error)

func StdLimitReader

func StdLimitReader(r io.Reader, n int64) io.Reader

func StdMultiReader

func StdMultiReader(readers ...io.Reader) io.Reader

func StdMultiWriter

func StdMultiWriter(writers ...io.Writer) io.Writer

func StdNewOffsetWriter added in v1.1.0

func StdNewOffsetWriter(w io.WriterAt, off int64) *io.OffsetWriter

func StdNewSectionReader added in v1.1.0

func StdNewSectionReader(r io.ReaderAt, off int64, n int64) *io.SectionReader

func StdNopCloser

func StdNopCloser(r io.Reader) io.ReadCloser

func StdPipe

func StdPipe() (*io.PipeReader, *io.PipeWriter)

func StdReadAll

func StdReadAll(r io.Reader) ([]byte, error)

func StdReadAtLeast

func StdReadAtLeast(r io.Reader, buf []byte, min int) (n int, err error)

func StdReadFull

func StdReadFull(r io.Reader, buf []byte) (n int, err error)

func StdTeeReader added in v1.1.0

func StdTeeReader(r io.Reader, w io.Writer) io.Reader

func StdWriteString

func StdWriteString(w io.Writer, s string) (n int, err error)

func Stream added in v1.1.0

func Stream(ctx context.Context, srcPath string, dst io.Writer) (int64, error)

Stream opens the file at the source path and streams its content to the destination writer. This function is memory-efficient and suitable for large files.

Types

type ByteReader

type ByteReader = io.ByteReader

type ByteScanner

type ByteScanner = io.ByteScanner

type ByteWriter

type ByteWriter = io.ByteWriter

type Closer

type Closer = io.Closer

type DirEntry added in v0.3.13

type DirEntry = fs.DirEntry

Standard library fs types.

type FileInfo

type FileInfo = fs.FileInfo

Standard library fs types.

type LimitedReader added in v1.1.0

type LimitedReader = io.LimitedReader

type OffsetWriter

type OffsetWriter = io.OffsetWriter

type PipeReader added in v1.1.0

type PipeReader = io.PipeReader

type PipeWriter added in v1.1.0

type PipeWriter = io.PipeWriter

type ReadCloser

type ReadCloser = io.ReadCloser

type ReadDirFile added in v0.3.13

type ReadDirFile = fs.ReadDirFile

Standard library fs types.

type ReadSeekCloser

type ReadSeekCloser = io.ReadSeekCloser

type ReadSeeker

type ReadSeeker = io.ReadSeeker

type ReadWriteCloser

type ReadWriteCloser = io.ReadWriteCloser

type ReadWriteSeeker

type ReadWriteSeeker = io.ReadWriteSeeker

type ReadWriter added in v1.1.0

type ReadWriter = io.ReadWriter

type Reader

type Reader = io.Reader

type ReaderAt

type ReaderAt = io.ReaderAt

type ReaderFrom

type ReaderFrom = io.ReaderFrom

type RuneReader

type RuneReader = io.RuneReader

type RuneScanner

type RuneScanner = io.RuneScanner

type SectionReader

type SectionReader = io.SectionReader

type Seeker

type Seeker = io.Seeker

type StringWriter added in v0.3.13

type StringWriter = io.StringWriter

type WriteCloser

type WriteCloser = io.WriteCloser

type WriteSeeker added in v1.1.0

type WriteSeeker = io.WriteSeeker

type Writer

type Writer = io.Writer

type WriterAt

type WriterAt = io.WriterAt

type WriterTo

type WriterTo = io.WriterTo

Jump to

Keyboard shortcuts

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