Documentation ¶
Overview ¶
Package unixfs implements a data format for files in the IPFS filesystem It is not the only format in ipfs, but it is the one that the filesystem assumes
Index ¶
- Constants
- Variables
- func BytesForMetadata(m *Metadata) ([]byte, error)deprecated
- func DataSize(data []byte) (uint64, error)deprecated
- func EmptyDirNode() *dag.ProtoNodedeprecated
- func EmptyFileNode() *dag.ProtoNodedeprecated
- func FilePBData(data []byte, totalsize uint64) []bytedeprecated
- func FolderPBData() []bytedeprecated
- func FromBytes(data []byte) (*pb.Data, error)deprecated
- func HAMTShardData(data []byte, fanout uint64, hashType uint64) ([]byte, error)deprecated
- func ReadUnixFSNodeData(node ipld.Node) (data []byte, err error)deprecated
- func SymlinkData(path string) ([]byte, error)deprecated
- func UnwrapData(data []byte) ([]byte, error)deprecated
- func WrapData(b []byte) []bytedeprecated
- type FSNodedeprecated
- func (n *FSNode) AddBlockSize(s uint64)
- func (n *FSNode) BlockSize(i int) uint64
- func (n *FSNode) BlockSizes() []uint64
- func (n *FSNode) Data() []byte
- func (n *FSNode) Fanout() uint64
- func (n *FSNode) FileSize() uint64
- func (n *FSNode) GetBytes() ([]byte, error)
- func (n *FSNode) HashType() uint64
- func (n *FSNode) IsDir() bool
- func (n *FSNode) NumChildren() int
- func (n *FSNode) RemoveAllBlockSizes()
- func (n *FSNode) RemoveBlockSize(i int)
- func (n *FSNode) SetData(newData []byte)
- func (n *FSNode) Type() pb.Data_DataType
- func (n *FSNode) UpdateFilesize(filesizeDiff int64)
- type LinkResultdeprecated
- type Metadatadeprecated
Constants ¶
const ( // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.TRaw TRaw = pb.Data_Raw // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.TFile TFile = pb.Data_File // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.TDirectory TDirectory = pb.Data_Directory // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.TMetadata TMetadata = pb.Data_Metadata // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.TSymlink TSymlink = pb.Data_Symlink // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.THAMTShard THAMTShard = pb.Data_HAMTShard )
Shorthands for protobuffer types
Variables ¶
var ( // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.ErrMalformedFileFormat ErrMalformedFileFormat = errors.New("malformed data in file format") // Deprecated: use github.com/ipfs/boxo/ipld/unixfs.ErrUnrecognizedType ErrUnrecognizedType = errors.New("unrecognized node type") )
Common errors
Functions ¶
func BytesForMetadata
deprecated
func DataSize
deprecated
DataSize returns the size of the contents in protobuf wrapped slice. For raw data it simply provides the length of it. For Data_Files, it will return the associated filesize. Note that Data_Directories will return an error.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs.DataSize
func EmptyDirNode
deprecated
func EmptyFileNode
deprecated
added in
v0.2.6
func FilePBData
deprecated
func FolderPBData
deprecated
func FolderPBData() []byte
FolderPBData returns Bytes that represent a Directory.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs.FolderPBData
func ReadUnixFSNodeData
deprecated
func SymlinkData
deprecated
func UnwrapData
deprecated
Types ¶
type FSNode
deprecated
type FSNode struct {
// contains filtered or unexported fields
}
An FSNode represents a filesystem object using the UnixFS specification.
The `NewFSNode` constructor should be used instead of just calling `new(FSNode)` to guarantee that the required (`Type` and `Filesize`) fields in the `format` structure are initialized before marshaling (in `GetBytes()`).
Deprecated: use github.com/ipfs/boxo/ipld/unixfs.FSNode
func ExtractFSNode
deprecated
func FSNodeFromBytes
deprecated
func NewFSNode
deprecated
func NewFSNode(dataType pb.Data_DataType) *FSNode
NewFSNode creates a new FSNode structure with the given `dataType`.
It initializes the (required) `Type` field (that doesn't have a `Set()` accessor so it must be specified at creation), otherwise the `Marshal()` method in `GetBytes()` would fail (`required field "Type" not set`).
It also initializes the `Filesize` pointer field to ensure its value is never nil before marshaling, this is not a required field but it is done to be backwards compatible with previous `go-ipfs` versions hash. (If it wasn't initialized there could be cases where `Filesize` could have been left at nil, when the `FSNode` was created but no data or child nodes were set to adjust it, as is the case in `NewLeaf()`.)
Deprecated: use github.com/ipfs/boxo/ipld/unixfs.NewFSNode
func (*FSNode) AddBlockSize ¶
AddBlockSize adds the size of the next child block of this node
func (*FSNode) BlockSize ¶
BlockSize returns the block size indexed by `i`. TODO: Evaluate if this function should be bounds checking.
func (*FSNode) BlockSizes ¶
BlockSizes gets blocksizes of format
func (*FSNode) NumChildren ¶
NumChildren returns the number of child blocks of this node
func (*FSNode) RemoveAllBlockSizes ¶
func (n *FSNode) RemoveAllBlockSizes()
RemoveAllBlockSizes removes all the child block sizes of this node.
func (*FSNode) RemoveBlockSize ¶
RemoveBlockSize removes the given child block's size.
func (*FSNode) SetData ¶
SetData sets the `Data` field from the internal `format` updating its `Filesize`.
func (*FSNode) Type ¶
func (n *FSNode) Type() pb.Data_DataType
Type retrieves the `Type` field from the internal `format`.
func (*FSNode) UpdateFilesize ¶
UpdateFilesize updates the `Filesize` field from the internal `format` by a signed difference (`filesizeDiff`). TODO: Add assert to check for `Filesize` > 0?
type LinkResult
deprecated
type Metadata
deprecated
Metadata is used to store additional FSNode information.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs.Metadata
func MetadataFromBytes
deprecated
Directories ¶
Path | Synopsis |
---|---|
Package hamt implements a Hash Array Mapped Trie over ipfs merkledag nodes.
|
Package hamt implements a Hash Array Mapped Trie over ipfs merkledag nodes. |
Package importer implements utilities used to create IPFS DAGs from files and readers.
|
Package importer implements utilities used to create IPFS DAGs from files and readers. |
balanced
Package balanced provides methods to build balanced DAGs, which are generalistic DAGs in which all leaves (nodes representing chunks of data) are at the same distance from the root.
|
Package balanced provides methods to build balanced DAGs, which are generalistic DAGs in which all leaves (nodes representing chunks of data) are at the same distance from the root. |
trickle
Package trickle allows to build trickle DAGs.
|
Package trickle allows to build trickle DAGs. |
Package io implements convenience objects for working with the ipfs unixfs data format.
|
Package io implements convenience objects for working with the ipfs unixfs data format. |
Package mod provides DAG modification utilities to, for example, insert additional nodes in a unixfs DAG or truncate them.
|
Package mod provides DAG modification utilities to, for example, insert additional nodes in a unixfs DAG or truncate them. |
private
|
|