fs

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fs implements a non-hierarchical file store using the underlying (disk) file system.

A file store contains directories named after UUIDs, each containing the following files:

name    the file name (``basename'')
type    the file's MIME type
data    the file data

This is not meant for anything for which the word “scale” plays any role at all, ever, anywhere.

TODO: should io/fs ever support writable file systems, use one of those instead of the “disk” (os.Open & Co.) (see https://github.com/golang/go/issues/45757)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS struct {
	// Root is the path of the file store, relative to the process's working
	// directory or absolute.
	Root string
}

FS is an on-disk file store.

func (*FS) Check

func (fs *FS) Check() error

Check checks whether the file store is operable, ie. whether fs.Root exists and is a directory.

func (*FS) Open

func (fs *FS) Open(name string) (fs.File, error)

Open searches for and opens the file with the given name.

func (*FS) OpenUUID

func (fs *FS) OpenUUID(id uuid.UUID) (fs.File, error)

OpenUUID opens the file with the given UUID.

func (*FS) RemoveUUID

func (fs *FS) RemoveUUID(id uuid.UUID) error

func (*FS) Store

func (fs *FS) Store(id uuid.UUID, name, contentType string, data io.Reader) error

type File

type File struct {
	*os.File
	// contains filtered or unexported fields
}

File is a file handle with its associated ID.

func (File) Stat

func (f File) Stat() (fs.FileInfo, error)

type FileInfo

type FileInfo struct {
	os.FileInfo
	// contains filtered or unexported fields
}

func (FileInfo) ContentType

func (fi FileInfo) ContentType() string

func (FileInfo) ID

func (fi FileInfo) ID() uuid.UUID

func (FileInfo) Name

func (fi FileInfo) Name() string

func (FileInfo) Sys

func (fi FileInfo) Sys() interface{}

Jump to

Keyboard shortcuts

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