storage

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const CidBufferSize = 64

Variables

View Source
var ContentCloseFile = func(contentId *Content) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var ContentFileCid = func(contentId *Content, cidPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var ContentPushFile = func(contentId *Content, cidPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var ContentReadFile = func(contentId *Content, buf *byte, bufLen uint32, dataPtr *byte, readPtr *int32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var ContentSeekFile = func(contentId *Content, offset int64, whence int, offsetPtr *int) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var ContentWriteFile = func(contentId *Content, buf *byte, bufLen uint32, writePtr *int32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageAddFile = func(storageId uint32, fileName string, versionPtr *uint32, bufPtr *byte, bufLen uint32, overWrite uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCapacity = func(storageId uint32, capacityPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCapacitySize = func(storageId uint32, sizePtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCid = func(cidPtr *byte, idPtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCidSize = func(storageId uint32, fileName string, idPtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCloseFile = func(storageId uint32, fd uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCurrentVersion = func(filename string, versionPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageCurrentVersionSize = func(storageId uint32, fileName string, sizePtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageDeleteFile = func(storageId uint32, fileName string, version uint32, all uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageGet = func(storageName string, idPtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageGetFile = func(storageId uint32, fileName string, version uint32, fdPtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageListFiles = func(storageId uint32, bufPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageListFilesSize = func(storageId uint32, sizePtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageListVersions = func(storageId uint32, fileName string, versionPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageListVersionsSize = func(storageId uint32, fileName string, sizePtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageNew = func(storageName string, idPtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageNewContent = func(contentId *Content) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageOpenCid = func(contentId *Content, cid *byte, cidSize uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageReadFile = func(storageId uint32, fd uint32, buf *byte, bufSize uint32, count *uint32) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageUsed = func(storageId uint32, usedPtr *byte) (error errno.Error) {
	return errno.ErrorNone
}
View Source
var StorageUsedSize = func(storageId uint32, sizePtr *uint32) (error errno.Error) {
	return errno.ErrorNone
}

Functions

This section is empty.

Types

type Content added in v0.1.24

type Content struct{}

func Create added in v0.1.24

func Create() (*Content, error)

Create creates and returns the new content.

func Open added in v0.1.24

func Open(_cid cid.Cid) (*Content, error)

Open creates a new content using the cid given as the file. Returns a new content.

func (*Content) Cid added in v0.1.24

func (c *Content) Cid() (cid.Cid, error)

Cid returns the cid of the file and an error.

func (*Content) Close added in v0.1.24

func (c *Content) Close() error

Close closes the file associated with the content. Returns an error.

func (*Content) Push added in v0.1.24

func (c *Content) Push() (cid.Cid, error)

Push adds the file into the network. Updates the cid of the file. Returns cid and an error

func (*Content) Read added in v0.1.24

func (c *Content) Read(p []byte) (int, []byte, error)

Read reads up to len p in the file. Returns how much was read and an error.

func (*Content) Seek added in v0.1.24

func (c *Content) Seek(offset int64, whence int) (int64, error)

Seek moves to a position inside the file. Offset is how much to move the current position Whence has three options: 0 = SeekStart, 1 = SeekCurrent, or 2 = SeekEnd Combines both offset and whence to find a new offset inside the file Returns the new offset and an error

func (*Content) Write added in v0.1.24

func (c *Content) Write(p []byte) (int, error)

Write writes the passed in data into the file. Returns how much was written and an error.

type DefaultFile

type DefaultFile interface {
	Add(data []byte, overWrite bool) (int, error)
	GetFile() (file *StorageFile, err error)
	Delete() error
	DeleteAllVersions() error
	CurrentVersion() (int, error)
	Versions() ([]string, error)
}

type File

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

func (*File) Add added in v0.1.20

func (f *File) Add(data []byte, overWrite bool) (int, error)

Add uses the data and overwrite given and adds the file to the storage. If overwrite is set to true then the current version number is not updated, and the data for the current version is updated. If overwrite is set to false, then for versioning enabled storages a new version is created For versioning disabled storages, file is only added if there is no file with the same name in the current storage. Returns the current version of the file.

func (*File) CurrentVersion added in v0.1.20

func (f *File) CurrentVersion() (int, error)

Current version looks up in the storage the latest version that is stored for that specific file. Returns the latest version for the file, if found, and an error.

func (*File) Delete added in v0.1.20

func (f *File) Delete() error

Delete uses the current file structure and the given version to delete the specific version of a file from the storage. Returns an error

func (*File) DeleteAllVersions

func (f *File) DeleteAllVersions() error

DeleteAllVersions uses the current file and deletes all version of it in the storage. Returns an error

func (*File) GetFile

func (f *File) GetFile() (file *StorageFile, err error)

GetFile grabs the the file from the storage Returns the file and an error

func (*File) Version

func (f *File) Version(version uint32) *VersionedFile

Version uses current file and given versions to create a new instance of VersionedFile Returns the created VersionedFile structure.

func (*File) Versions added in v0.1.20

func (f *File) Versions() ([]string, error)

ListVersions uses the current file and looks up all version of the file. Returns []string of all the versions and an error

type Storage

type Storage uint32

func Get

func Get(storageName string) (Storage, error)

Get returns the storage with given name. Returns the storage if it exists and an error.

func New

func New(storageName string) (Storage, error)

New creates a new storage Returns a storage and an error

func (Storage) Cid added in v0.1.20

func (s Storage) Cid(fileName string) (string, error)

Cid looks up the given filename in the given storage. Returns the cid corresponding to the file if found and an error.

func (Storage) File

func (s Storage) File(fileName string) *File

File uses the name passed in and creates a new instance of File that holds the storage and filename. Returns the File structure.

func (Storage) ListFiles added in v0.1.20

func (s Storage) ListFiles() ([]File, error)

ListFiles looks up all saved files in the given storage. Returns an array of all Files found in the storage and an error.

func (Storage) RemainingCapacity

func (s Storage) RemainingCapacity() (int, error)

Remaining capacity loops through to given storage and calculates how much space left is available. Returns the remaining space available and an error.

type StorageFile

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

func (*StorageFile) Close

func (file *StorageFile) Close() error

Close closes the current file Returns an error

func (*StorageFile) Read

func (file *StorageFile) Read(p []byte) (int, error)

Read reads the given bytes Returns an int of how much was read and an error

type VersionedFile

type VersionedFile struct {
	DefaultFile
}

Jump to

Keyboard shortcuts

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