fs

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyStubsInStubs added in v0.2.0

func AnyStubsInStubs(src, tgt PageStubs) (found bool)

func CheckForFileData

func CheckForFileData(fs FileSystem, url, mount string) (data []byte, mime, path string, ok bool)

func EnumerateCheckPaths

func EnumerateCheckPaths(src string) (checkPaths []string)

func FileExists

func FileExists(path string) (exists bool)

func FindFileMime

func FindFileMime(path string) (mime string, err error)

func FindFileShasum

func FindFileShasum(path string) (shasum string, err error)

func ListAllDirs

func ListAllDirs(path string) (dirs []string, err error)

func ListAllFiles

func ListAllFiles(path string) (files []string, err error)

func ListDirs

func ListDirs(path string) (dirs []string, err error)

func ListFiles

func ListFiles(path string) (files []string, err error)

func LookupFilePath added in v0.2.0

func LookupFilePath(fs FileSystem, basePath string, extensions ...string) (path string, present bool)

func PruneRootFrom added in v0.2.0

func PruneRootFrom[T string | []string](root string, path T) (pruned T)

func PruneRootFromSlice added in v0.2.1

func PruneRootFromSlice(root string, slice []string) (pruned []string)

func PruneRootFromString added in v0.2.1

func PruneRootFromString(root string, path string) (pruned string)

func PruneRootPrefixes added in v0.2.0

func PruneRootPrefixes(path string) (pruned string)

func RegisterFileSystem

func RegisterFileSystem(mount string, f FileSystem)

func RegisteredFileSystems

func RegisteredFileSystems() (registered map[string][]FileSystem)

Types

type File

type File struct {
	Path string
	Name string
	Extn string
	Mime string
	Data []byte
}

func New

func New(path string) (file *File, err error)

func (File) String

func (f File) String() string

type FileSystem

type FileSystem interface {
	CloneROFS() (cloned FileSystem)
	Name() (name string)
	Open(path string) (fh fs.File, err error)
	ListDirs(path string) (paths []string, err error)
	ListFiles(path string) (paths []string, err error)
	ListAllDirs(path string) (paths []string, err error)
	ListAllFiles(path string) (paths []string, err error)
	ReadDir(path string) (paths []fs.DirEntry, err error)
	ReadFile(path string) (content []byte, err error)
	MimeType(path string) (mime string, err error)
	Shasum(path string) (shasum string, err error)
	FileCreated(path string) (created int64, err error)
	LastModified(path string) (dateTime int64, err error)
	Exists(path string) (exists bool)
	FileStats(path string) (mime, shasum string, created, updated time.Time, err error)
	FindFilePath(path string, extensions ...string) (realpath string, err error)
	ReadPageMatter(path string) (pm *matter.PageMatter, err error)
}

func Wrap

func Wrap(path string, fs FileSystem) (out FileSystem, err error)

type GormFileSystem added in v0.2.2

type GormFileSystem interface {
	GormTx() (tx *gorm.DB)
	FindPathsWhere(path string, expressions ...clause.Expression) (found []string, err error)
}

type PageStub added in v0.2.0

type PageStub struct {
	Origin   string
	FS       FileSystem
	Point    string
	Shasum   string
	Source   string
	Language language.Tag
	Fallback language.Tag
	EnjinCtx beContext.Context
}

func NewPageStub added in v0.2.0

func NewPageStub(origin string, enjin beContext.Context, bfs FileSystem, point, source, shasum string, fallback language.Tag) (s *PageStub)

type PageStubs added in v0.2.0

type PageStubs []*PageStub

func (PageStubs) GetShasum added in v0.2.0

func (s PageStubs) GetShasum(shasum string) (found *PageStub)

func (PageStubs) GetSource added in v0.2.0

func (s PageStubs) GetSource(source string) (found *PageStub)

func (PageStubs) HasShasum added in v0.2.0

func (s PageStubs) HasShasum(shasum string) (found bool)

func (PageStubs) Random added in v0.2.0

func (s PageStubs) Random() (stub *PageStub)

type QueryFileSystem added in v0.2.0

type QueryFileSystem interface {
	FindPathsWithContextKey(path, key string) (found []string, err error)
	FindPathsWhereContextKeyEquals(path, key string, value interface{}) (found []string, err error)
	FindPathsWhereContextEquals(path string, conditions map[string]interface{}) (found []string, err error)
	FindPathsWhereContext(path string, orJsonConditions ...map[string]interface{}) (found []string, err error)
}

type RWFileSystem added in v0.1.0

type RWFileSystem interface {
	FileSystem

	CloneRWFS() (cloned RWFileSystem)
	BeginTransaction()
	RollbackTransaction()
	CommitTransaction()
	EndTransaction()

	MakeDir(path string, perm os.FileMode) (err error)
	MakeDirAll(path string, perm os.FileMode) (err error)

	Remove(path string) (err error)
	RemoveAll(path string) (err error)

	WriteFile(path string, data []byte, perm os.FileMode) (err error)
	WritePageMatter(pm *matter.PageMatter) (err error)
	RemovePageMatter(path string) (err error)
}

func WrapRW added in v0.1.0

func WrapRW(path string, fs RWFileSystem) (out RWFileSystem, err error)

type ValueStubPair added in v0.2.0

type ValueStubPair struct {
	Value interface{}
	Stub  *PageStub
}

type WrapFileSystem

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

func (WrapFileSystem) CloneROFS added in v0.2.5

func (w WrapFileSystem) CloneROFS() (cloned FileSystem)

func (WrapFileSystem) Exists

func (w WrapFileSystem) Exists(path string) (exists bool)

func (WrapFileSystem) FileCreated

func (w WrapFileSystem) FileCreated(path string) (created int64, err error)

func (WrapFileSystem) FileStats added in v0.1.0

func (w WrapFileSystem) FileStats(path string) (mime, shasum string, created, updated time.Time, err error)

func (WrapFileSystem) FindFilePath added in v0.2.0

func (w WrapFileSystem) FindFilePath(prefix string, extensions ...string) (path string, err error)

func (WrapFileSystem) LastModified

func (w WrapFileSystem) LastModified(path string) (updated int64, err error)

func (WrapFileSystem) ListAllDirs

func (w WrapFileSystem) ListAllDirs(path string) (paths []string, err error)

func (WrapFileSystem) ListAllFiles

func (w WrapFileSystem) ListAllFiles(path string) (paths []string, err error)

func (WrapFileSystem) ListDirs

func (w WrapFileSystem) ListDirs(path string) (paths []string, err error)

func (WrapFileSystem) ListFiles

func (w WrapFileSystem) ListFiles(path string) (paths []string, err error)

func (WrapFileSystem) MimeType

func (w WrapFileSystem) MimeType(path string) (mime string, err error)

func (WrapFileSystem) Name

func (w WrapFileSystem) Name() (name string)

func (WrapFileSystem) Open

func (w WrapFileSystem) Open(path string) (file fs.File, err error)

func (WrapFileSystem) ReadDir

func (w WrapFileSystem) ReadDir(path string) (entries []fs.DirEntry, err error)

func (WrapFileSystem) ReadFile

func (w WrapFileSystem) ReadFile(path string) (data []byte, err error)

func (WrapFileSystem) ReadPageMatter added in v0.2.0

func (w WrapFileSystem) ReadPageMatter(path string) (pm *matter.PageMatter, err error)

func (WrapFileSystem) Shasum

func (w WrapFileSystem) Shasum(path string) (shasum string, err error)

type WrapRWFileSystem added in v0.1.0

type WrapRWFileSystem struct {
	WrapFileSystem
	// contains filtered or unexported fields
}

func (WrapRWFileSystem) BeginTransaction added in v0.2.5

func (w WrapRWFileSystem) BeginTransaction()

func (WrapRWFileSystem) CloneRWFS added in v0.2.5

func (w WrapRWFileSystem) CloneRWFS() (cloned RWFileSystem)

func (WrapRWFileSystem) CommitTransaction added in v0.2.5

func (w WrapRWFileSystem) CommitTransaction()

func (WrapRWFileSystem) EndTransaction added in v0.2.5

func (w WrapRWFileSystem) EndTransaction()

func (WrapRWFileSystem) MakeDir added in v0.1.0

func (w WrapRWFileSystem) MakeDir(path string, perm os.FileMode) (err error)

func (WrapRWFileSystem) MakeDirAll added in v0.1.0

func (w WrapRWFileSystem) MakeDirAll(path string, perm os.FileMode) (err error)

func (WrapRWFileSystem) Remove added in v0.1.0

func (w WrapRWFileSystem) Remove(path string) (err error)

func (WrapRWFileSystem) RemoveAll added in v0.1.0

func (w WrapRWFileSystem) RemoveAll(path string) (err error)

func (WrapRWFileSystem) RemovePageMatter added in v0.2.0

func (w WrapRWFileSystem) RemovePageMatter(path string) (err error)

func (WrapRWFileSystem) RollbackTransaction added in v0.2.5

func (w WrapRWFileSystem) RollbackTransaction()

func (WrapRWFileSystem) WriteFile added in v0.1.0

func (w WrapRWFileSystem) WriteFile(path string, data []byte, perm os.FileMode) (err error)

func (WrapRWFileSystem) WritePageMatter added in v0.2.0

func (w WrapRWFileSystem) WritePageMatter(pm *matter.PageMatter) (err error)

Jump to

Keyboard shortcuts

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