filebuf

package module
v0.0.0-...-7d8c00c Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 5 Imported by: 1

README

Rope file buffer package for fast editing operations on large files.

Maintain a tree, where each node is 'backed' by a buffer or a portion
of a file.  Then editing operation such as deletions and insertions can
be done efficiently, not by changing a file or buffer, but rather by
modifying the tree-overlay.

Documentation

Overview

Package for efficient editing operations on big files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

implements io.ReadWriteSeeker

func NewEmpty

func NewEmpty() *Buffer

func NewMem

func NewMem(b []byte) *Buffer

Use byte array b as source for a filebuffer

func OpenFile

func OpenFile(f string) (*Buffer, error)

Open file 'f' as source for a filebuffer As long as you are using buffers predicated on 'f', you probably shouldn't change the file on disk

func (*Buffer) Copy

func (fb *Buffer) Copy(offset int64, size int64) *Buffer

Copy size bytes at offset

func (*Buffer) Cut

func (fb *Buffer) Cut(offset int64, size int64) *Buffer

Cut size bytes at offset

func (*Buffer) Dump

func (fb *Buffer) Dump(out io.Writer)

Dump contents to out

func (*Buffer) Insert

func (fb *Buffer) Insert(offset int64, bs []byte) error

Insert a byte slice

func (*Buffer) Insert1

func (fb *Buffer) Insert1(offset int64, b byte) error

Insert 1 byte

func (*Buffer) Iter

func (fb *Buffer) Iter(cb func([]byte) bool)

iterate over the file, give the callback byte slices for READING ONLY

func (*Buffer) IterFrom

func (fb *Buffer) IterFrom(from int64, cb func([]byte) bool)

Same as Iter, but start at offset

func (*Buffer) Paste

func (fb *Buffer) Paste(offset int64, paste *Buffer)

Paste buf at offset (copies the paste buffer)

func (*Buffer) Read

func (fb *Buffer) Read(p []byte) (int, error)

io.Reader

func (*Buffer) Remove

func (fb *Buffer) Remove(offset int64, size int64)

func (*Buffer) Seek

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

io.Seeker

func (*Buffer) Size

func (fb *Buffer) Size() int64

func (*Buffer) Write

func (fb *Buffer) Write(p []byte) (int, error)

io.Writer

Jump to

Keyboard shortcuts

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