fs

package
v0.0.0-...-c3be179 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(data []byte) []byte

Hash creates a sha256 hash of data

func MakeTree

func MakeTree(path string) (tree.Node, error)

MakeTree recursively creates a tree given a valid path

func MultiHash

func MultiHash(sha256Hash []byte) string

MultiHash creates a multihash using the sha256 algorithm, then encodes it in base58

func SprintTree

func SprintTree(t tree.Node, tabLvl int) string

SprintTree is used to recursively print a tree

func UnHash

func UnHash(hash string) ([]byte, error)

UnHash retuns the original hash given a base58-encoded multihash

Types

type Dir

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

Dir represents a dir node implemented as a tree.Node

func (Dir) Hash

func (d Dir) Hash() []byte

Hash returns the hash of combination of prehash and name of the directory

func (Dir) IsDir

func (d Dir) IsDir() bool

IsDir always returns true

func (Dir) Name

func (d Dir) Name() string

Name returns the name of the directory

func (Dir) PreHash

func (d Dir) PreHash() []byte

PreHash returns the combined hash of all the subnodes of the directory

func (Dir) Sort

func (d Dir) Sort()

Sort alphabetically sorts the subnodes of d

func (Dir) Subnodes

func (d Dir) Subnodes() []tree.Node

Subnodes returns the subdirs and files of the directory

type File

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

File represents a file as an implementation of tree.Node

func MakeFile

func MakeFile(path string) (*File, error)

MakeFile creates a File given a valid path

func (File) Hash

func (f File) Hash() []byte

Hash returns the hash of combination of content and name of the file

func (File) IsDir

func (f File) IsDir() bool

IsDir always retuns false

func (File) Name

func (f File) Name() string

Name returns the basename of the file

func (File) PreHash

func (f File) PreHash() []byte

PreHash returns the hash of the content of the file

func (File) Subnodes

func (f File) Subnodes() []tree.Node

Subnodes returns a nil pointer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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