fs

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEFAULT_RETRIES = 5
)

Functions

This section is empty.

Types

type Backend

type Backend struct {
	BaseDir string
	Retries int
}

func NewBackend

func NewBackend(baseDir string, retries int) *Backend

func (*Backend) Delete

func (b *Backend) Delete(path string) error

Deletes the file referenced by name. If deletion is not supported on the target storage system this will return ErrNotImplemented.

func (*Backend) Exists

func (b *Backend) Exists(path string) (bool, error)

Returns True if a file referenced by the given name already exists in the storage system.

func (*Backend) GetAlternateName

func (b *Backend) GetAlternateName(fileRoot, fileExt string) string

Returns an alternative filename based on the file_root and file_ext parameters, an underscore plus a random 7 character alphanumeric string is appended to the filename before the extension.

func (*Backend) GetAvailableName

func (b *Backend) GetAvailableName(path string, retries int, max_length int) (string, error)

Returns a filename based on the name parameter that’s free and available for new content to be written to on the target storage system.

The length of the filename will not exceed max_length, if provided. If a free unique filename cannot be found, ErrSuspiciousOperation will be returned.

func (*Backend) ListDir

func (b *Backend) ListDir(path string) ([]string, error)

Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files. For storage systems that aren’t able to provide such a listing, this will return ErrNotImplemented.

func (*Backend) Open

func (b *Backend) Open(name string) (mediafiles.StoredObject, error)

func (*Backend) Save

func (b *Backend) Save(path string, file io.Reader, maxLength ...int) (string, error)

Saves a new file using the storage system, preferably with the name specified. If there already exists a file with this name name, the storage system may modify the filename as necessary to get a unique name. The actual name of the stored file will be returned.

The maxLength parameter is passed to GetAvailableName() and is used to limit the length of the filename before saving. If the file is too large to be saved, this will raise a SuspiciousOperation exception.

func (*Backend) Stat

func (b *Backend) Stat(path string) (mediafiles.FileHeader, error)

type File

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

func (*File) Close

func (f *File) Close() error

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

func (*File) Stat

func (f *File) Stat() (mediafiles.FileHeader, error)

type FileHeader

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

func (*FileHeader) Name

func (h *FileHeader) Name() string

func (*FileHeader) Path

func (h *FileHeader) Path() string

func (*FileHeader) Size

func (h *FileHeader) Size() int64

func (*FileHeader) TimeAccessed

func (h *FileHeader) TimeAccessed() (t time.Time, err error)

func (*FileHeader) TimeCreated

func (h *FileHeader) TimeCreated() (t time.Time, err error)

func (*FileHeader) TimeModified

func (h *FileHeader) TimeModified() (t time.Time, err error)

Jump to

Keyboard shortcuts

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