sqlfs

package module
v0.0.0-...-027d63f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: MIT Imports: 12 Imported by: 0

README

go-sqlfs

SQL based filesystem using go-billy

Documentation

Overview

Package sqlfs provides an SQL based filesystem

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(s *Storage) (billy.Filesystem, error)

New returns a new SQLite filesystem.

Types

type Event

type Event struct {
	Type    EventType
	Paths   []string
	Content []byte
}

type EventType

type EventType int8
const (
	FileCreatedEvent EventType = 1
	FileRenamedEvent EventType = 2
	FileRemovedEvent EventType = 3
	FileUpdatedEvent EventType = 4
)

type File

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

File represents a file.

func NewFile

func NewFile(s *Storage, path string, data []byte, mode, flag int, modTime time.Time) *File

NewFile creates a new file for given path, data, mode, flag and modTime

func (*File) Close

func (f *File) Close() error

Close implements billy.File

func (*File) Content

func (f *File) Content() []byte

Content returns the file content

func (*File) Duplicate

func (f *File) Duplicate(filename string, mode os.FileMode, flag int, modTime time.Time) billy.File

Duplicate returns a billy.File duplicate of file defined by filename

func (*File) Flag

func (f *File) Flag() int

Flag returns the file flag

func (*File) Lock

func (f *File) Lock() error

Lock is a no-op in memfs.

func (*File) ModTime

func (f *File) ModTime() time.Time

ModTime returns the time this file was last modified

func (*File) Mode

func (f *File) Mode() os.FileMode

Mode returns the os.FileMode value

func (*File) Name

func (f *File) Name() string

Name implements billy.File

func (*File) Path

func (f *File) Path() string

Path returns the full path of the file

func (*File) Read

func (f *File) Read(b []byte) (int, error)

Read implements billy.File

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (int, error)

ReadAt implements billy.File

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek implements billy.File

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

Stat implements billy.File

func (*File) Truncate

func (f *File) Truncate(size int64) error

Truncate implements billy.File

func (*File) Unlock

func (f *File) Unlock() error

Unlock is a no-op in memfs.

func (*File) Write

func (f *File) Write(p []byte) (int, error)

Write implements billy.File

type FileInfo

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

FileInfo implements os.FileInfo

func (*FileInfo) IsDir

func (fi *FileInfo) IsDir() bool

IsDir implements os.FileInfo

func (*FileInfo) ModTime

func (fi *FileInfo) ModTime() time.Time

ModTime implements os.FileInfo

func (*FileInfo) Mode

func (fi *FileInfo) Mode() os.FileMode

Mode implements os.FileInfo

func (*FileInfo) Name

func (fi *FileInfo) Name() string

Name implements os.FileInfo

func (*FileInfo) SetName

func (fi *FileInfo) SetName(name string)

SetName sets the Name to specified name

func (*FileInfo) Size

func (fi *FileInfo) Size() int64

Size implements os.FileInfo

func (*FileInfo) Sys

func (*FileInfo) Sys() interface{}

Sys implements os.FileInfo

type FileInitializer

type FileInitializer func(path string, data []byte, mode, flag int, modTime time.Time) *File

FileInitializer creates a new file for given path, data...

type Handler

type Handler interface {
	Handle(*Event)
}

type NoOpHandler

type NoOpHandler struct{}

NoOpHandler provides a no operation handler

func (NoOpHandler) Handle

func (h NoOpHandler) Handle(*Event)

type Storage

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

func NewStorage

func NewStorage(s Storer) (*Storage, error)

NewStorage creates a new Storage for given Storer

func (*Storage) Children

func (s *Storage) Children(path string) ([]*File, error)

func (*Storage) Get

func (s *Storage) Get(path string) (*File, error)

func (*Storage) Handle

func (s *Storage) Handle(pattern string, handler Handler)

Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.

func (*Storage) Has

func (s *Storage) Has(path string) bool

func (*Storage) New

func (s *Storage) New(path string, mode os.FileMode, flag int) (*File, error)

func (*Storage) Remove

func (s *Storage) Remove(path string) error

func (*Storage) Rename

func (s *Storage) Rename(fromPath, toPath string) error

func (*Storage) Write

func (s *Storage) Write(path string, content []byte) error

type Storer

type Storer interface {
	// Initialize initializes the storer
	Initialize() error
	// Has checks whether or not given path exists
	Has(path string) bool
	// Create creates a new path with given mode and flag
	Create(f *File) error
	// Children returns the children of given path
	Children(fn FileInitializer, path, separator string) ([]*File, error)
	// Get returns the file on given path
	Get(fn FileInitializer, path string) (*File, error)
	// Rename renames file
	Rename(fromPath, toPath string) error
	// Remove removes file or directory on given path
	Remove(path string) error
	// Write writes file content to file in given path
	Write(path string, content []byte) error

	// Lock locks the file like e.g. flock. It protects against access from
	// other processes.
	Lock(path string) error
	// Unlock unlocks the file.
	Unlock(path string) error
}

Storer provides SQLite filesystem storer

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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