file

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B = 1 << (iota * 10)
	KB
	MB
	GB
	TB
	PB
)
View Source
const (
	RwAppendMode = os.O_CREATE | os.O_APPEND | os.O_RDWR
)

Variables

This section is empty.

Functions

func OutFsFile

func OutFsFile(fs fs.ReadFileFS, file string, out io.Writer) error

Types

type IO

type IO interface {
	// Name returns the name of the file
	Name() string

	// ReadAt read bytes from io start at offset
	ReadAt(p []byte, off int64) (n int, err error)

	// Write bytes to io
	Write(p []byte) (n int, err error)

	Seek(offset int64, whence int) (ret int64, err error)
	// Sync buffer to disk
	Sync() error

	// Close io and release resources
	Close() error
}

IO is the abstract of data file, define a set of interface methods to interact with data file how to read and write files depending on the IO underlying implementation

type StdFile

type StdFile struct {
	// contains filtered or unexported fields
}

func OpenStdFile

func OpenStdFile(filename string, flag int, mode os.FileMode) (*StdFile, error)

func (StdFile) Close

func (f StdFile) Close() error

func (StdFile) Name

func (f StdFile) Name() string

func (StdFile) ReadAt

func (f StdFile) ReadAt(p []byte, off int64) (n int, err error)

func (StdFile) Seek

func (f StdFile) Seek(offset int64, whence int) (ret int64, err error)

func (StdFile) Sync

func (f StdFile) Sync() error

func (StdFile) Write

func (f StdFile) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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