memfile

package
v1.2.2-sp7 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File is an in-memory emulation of the I/O operations of os.File. The zero value for File is an empty file ready to use.

func New

func New(b []byte) *File

New creates and initializes a new File using b as its initial contents. The new File takes ownership of b.

func (*File) Bytes

func (fb *File) Bytes() []byte

Bytes returns the full contents of the File. The result in only valid until the next Write, WriteAt, or Truncate call.

func (*File) Read

func (fb *File) Read(b []byte) (int, error)

Read reads up to len(b) bytes from the File. It returns the number of bytes read and any error encountered. At end of file, Read returns (0, io.EOF).

func (*File) ReadAt

func (fb *File) ReadAt(b []byte, offset int64) (int, error)

ReadAt reads len(b) bytes from the File starting at byte offset. It returns the number of bytes read and the error, if any. At end of file, that error is io.EOF.

func (*File) Seek

func (fb *File) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read or Write on file with offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end.

func (*File) Truncate

func (fb *File) Truncate(n int64) error

Truncate changes the size of the file. It does not change the I/O offset.

func (*File) Write

func (fb *File) Write(b []byte) (int, error)

Write writes len(b) bytes to the File. It returns the number of bytes written and an error, if any. If the current file offset is past the io.EOF, then the space in-between are implicitly filled with zero bytes.

func (*File) WriteAt

func (fb *File) WriteAt(b []byte, offset int64) (int, error)

WriteAt writes len(b) bytes to the File starting at byte offset. It returns the number of bytes written and an error, if any. If offset lies past io.EOF, then the space in-between are implicitly filled with zero bytes.

Jump to

Keyboard shortcuts

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