object

package
v1.48.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package object defines some useful Objects

Index

Constants

This section is empty.

Variables

View Source
var MemoryFs memoryFs

MemoryFs is an in memory Fs, it only supports FsInfo and Put

Functions

func NewStaticObjectInfo

func NewStaticObjectInfo(remote string, modTime time.Time, size int64, storable bool, hashes map[hash.Type]string, fs fs.Info) fs.ObjectInfo

NewStaticObjectInfo returns a static ObjectInfo If hashes is nil and fs is not nil, the hash map will be replaced with empty hashes of the types supported by the fs.

Types

type MemoryObject

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

MemoryObject is an in memory object

func NewMemoryObject

func NewMemoryObject(remote string, modTime time.Time, content []byte) *MemoryObject

NewMemoryObject returns an in memory Object with the modTime and content passed in

func (*MemoryObject) Content

func (o *MemoryObject) Content() []byte

Content returns the underlying buffer

func (*MemoryObject) Fs

func (o *MemoryObject) Fs() fs.Info

Fs returns read only access to the Fs that this object is part of

func (*MemoryObject) Hash

func (o *MemoryObject) Hash(h hash.Type) (string, error)

Hash returns the requested hash of the contents

func (*MemoryObject) ModTime

func (o *MemoryObject) ModTime() time.Time

ModTime returns the modification date of the file

func (*MemoryObject) Open

func (o *MemoryObject) Open(options ...fs.OpenOption) (io.ReadCloser, error)

Open opens the file for read. Call Close() on the returned io.ReadCloser

func (*MemoryObject) Remote

func (o *MemoryObject) Remote() string

Remote returns the remote path

func (*MemoryObject) Remove

func (o *MemoryObject) Remove() error

Remove this object

func (*MemoryObject) SetModTime

func (o *MemoryObject) SetModTime(modTime time.Time) error

SetModTime sets the metadata on the object to set the modification date

func (*MemoryObject) Size

func (o *MemoryObject) Size() int64

Size returns the size of the file

func (*MemoryObject) Storable

func (o *MemoryObject) Storable() bool

Storable says whether this object can be stored

func (*MemoryObject) String

func (o *MemoryObject) String() string

String returns a description of the Object

func (*MemoryObject) Update

func (o *MemoryObject) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error)

Update in to the object with the modTime given of the given size

This re-uses the internal buffer if at all possible.

Jump to

Keyboard shortcuts

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