go-unixfs: github.com/ipfs/go-unixfs/mod Index | Files

package mod

import "github.com/ipfs/go-unixfs/mod"

Package mod provides DAG modification utilities to, for example, insert additional nodes in a unixfs DAG or truncate them.

Index

Package Files

dagmodifier.go

Variables

var (
    ErrSeekFail           = errors.New("failed to seek properly")
    ErrUnrecognizedWhence = errors.New("unrecognized whence")
    ErrNotUnixfs          = errors.New("dagmodifier only supports unixfs nodes (proto or raw)")
)

Common errors

type DagModifier Uses

type DagModifier struct {
    Prefix    cid.Prefix
    RawLeaves bool
    // contains filtered or unexported fields
}

DagModifier is the only struct licensed and able to correctly perform surgery on a DAG 'file' Dear god, please rename this to something more pleasant

func NewDagModifier Uses

func NewDagModifier(ctx context.Context, from ipld.Node, serv ipld.DAGService, spl chunker.SplitterGen) (*DagModifier, error)

NewDagModifier returns a new DagModifier, the Cid prefix for newly created nodes will be inhered from the passed in node. If the Cid version if not 0 raw leaves will also be enabled. The Prefix and RawLeaves options can be overridden by changing them after the call.

func (*DagModifier) CtxReadFull Uses

func (dm *DagModifier) CtxReadFull(ctx context.Context, b []byte) (int, error)

CtxReadFull reads data from this dag starting at the current offset

func (*DagModifier) GetNode Uses

func (dm *DagModifier) GetNode() (ipld.Node, error)

GetNode gets the modified DAG Node

func (*DagModifier) HasChanges Uses

func (dm *DagModifier) HasChanges() bool

HasChanges returned whether or not there are unflushed changes to this dag

func (*DagModifier) Read Uses

func (dm *DagModifier) Read(b []byte) (int, error)

Read data from this dag starting at the current offset

func (*DagModifier) Seek Uses

func (dm *DagModifier) Seek(offset int64, whence int) (int64, error)

Seek modifies the offset according to whence. See unixfs/io for valid whence values.

func (*DagModifier) Size Uses

func (dm *DagModifier) Size() (int64, error)

Size returns the Filesize of the node

func (*DagModifier) Sync Uses

func (dm *DagModifier) Sync() error

Sync writes changes to this dag to disk

func (*DagModifier) Truncate Uses

func (dm *DagModifier) Truncate(size int64) error

Truncate truncates the current Node to 'size' and replaces it with the new one.

func (*DagModifier) Write Uses

func (dm *DagModifier) Write(b []byte) (int, error)

Write continues writing to the dag at the current offset

func (*DagModifier) WriteAt Uses

func (dm *DagModifier) WriteAt(b []byte, offset int64) (int, error)

WriteAt will modify a dag file in place

Package mod imports 12 packages (graph) and is imported by 1 packages. Updated 2019-01-31. Refresh now. Tools for package owners.