mmap

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadFD            = errors.New("mmap: bad file descriptor")
	ErrClosed           = errors.New("mmap: closed")
	ErrInvalidOffset    = errors.New("mmap: invalid offset")
	ErrNegativePosition = errors.New("mmap: negative position")
	ErrInvalidWhence    = errors.New("mmap: invalid whence")
)

Functions

This section is empty.

Types

type File

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

func Open

func Open(filename string) (*File, error)

Open memory-maps the named file for reading.

func OpenFile

func OpenFile(filename string, flag Flag) (*File, error)

OpenFile memory-maps the named file for reading/writing, depending on the flag value.

func (*File) Close

func (f *File) Close() error

Close closes the memory-mapped file.

func (*File) Len

func (f *File) Len() int

Len returns the length of the underlying memory-mapped file.

func (*File) Read

func (f *File) Read(p []byte) (int, error)

Read implements the io.Reader interface.

func (*File) ReadAt

func (f *File) ReadAt(p []byte, off int64) (int, error)

ReadAt implements the io.ReaderAt interface.

func (*File) ReadOff

func (f *File) ReadOff(off, length int) ([]byte, error)

func (*File) Seek

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

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

Stat returns the FileInfo structure describing file. If there is an error, it will be of type *os.PathError.

func (*File) Sync

func (f *File) Sync() error

Sync commits the current contents of the file to stable storage.

func (*File) Write

func (f *File) Write(p []byte) (int, error)

Write implements the io.Writer interface.

func (*File) WriteAt

func (f *File) WriteAt(p []byte, off int64) (int, error)

WriteAt implements the io.WriterAt interface.

type Flag

type Flag int

Flag specifies how a mmap file should be opened.

const (
	Read  Flag = 0x1 // Read enables read-access to a mmap file.
	Write Flag = 0x2 // Write enables write-access to a mmap file.
)

Jump to

Keyboard shortcuts

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