Documentation ¶
Index ¶
- Variables
- func DirEntriesToFileMetaInfos(fis []iofs.DirEntry) []fs.FileMetaInfo
- func GetVirtualFileInfo() (os.FileInfo, error)
- func Glob(afs afero.Fs, pattern string, handle func(fi fs.FileMetaInfo) (bool, error)) error
- func LstatIfPossible(fs afero.Fs, path string) (os.FileInfo, bool, error)
- func NewBaseFs(fs afero.Fs) afero.Fs
- func NewBasePathFs(source afero.Fs, path string) afero.Fs
- func NewHasBytesReceiver(delegate afero.Fs, shouldCheck func(name string) bool, ...) afero.Fs
- func NewHashingFs(delegate afero.Fs, hashReceiver FileHashReceiver) afero.Fs
- func NewReadOnlyFs(source afero.Fs) afero.Fs
- func RealFilename(cfs *ComponentFs, rel string) string
- func WalkFilesystems(afs afero.Fs, fn WalkFn) bool
- func WrapFilesystem(container, content afero.Fs) afero.Fs
- type ComponentFs
- func (cfs *ComponentFs) MakePathRelative(filename string, checkExists bool) (string, bool)
- func (cfs *ComponentFs) Open(name string) (afero.File, error)
- func (cfs *ComponentFs) RealDirs(from string) []string
- func (cfs *ComponentFs) ReverseLookup(filename string, checkExists bool) ([]ComponentPath, error)
- func (cfs *ComponentFs) Stat(name string) (os.FileInfo, error)
- func (cfs *ComponentFs) UnwrapFilesystem() afero.Fs
- type ComponentPath
- type ContentClass
- type DirFile
- type DirOpener
- type File
- type FileChangeDetector
- type FileHashReceiver
- type FileInfo
- func NewFileInfo(fi os.FileInfo, filename string) *FileInfo
- func NewFileInfoWithMeta(fi os.FileInfo, meta *FileMeta) *FileInfo
- func NewFileInfoWithName(filename string) *FileInfo
- func NewFileInfoWithNewMeta(fi os.FileInfo, meta *FileMeta) *FileInfo
- func NewFileInfoWithOpener(fi os.FileInfo, filename string, opener FileOpener) *FileInfo
- func NewFileInfoWithRoot(fi os.FileInfo, filename, root string, opener FileOpener) *FileInfo
- type FileMeta
- func (f *FileMeta) Component() string
- func (f *FileMeta) Copy() *FileMeta
- func (f *FileMeta) FileName() string
- func (f *FileMeta) Merge(from *FileMeta)
- func (f *FileMeta) NormalizedFilename() string
- func (f *FileMeta) Open() (afero.File, error)
- func (f *FileMeta) RelativeFilename() string
- func (f *FileMeta) Root() string
- type FileOpener
- type FilesystemsCollector
- type MetaProvider
- type ReverseLookupProvider
- type RootMapping
- type RootMappingFs
- func (rmfs *RootMappingFs) Mounts(base string) ([]fs.FileMetaInfo, error)
- func (rmfs *RootMappingFs) Open(name string) (afero.File, error)
- func (rmfs *RootMappingFs) ReverseLookup(filename string) ([]ComponentPath, error)
- func (rmfs *RootMappingFs) ReverseLookupComponent(component, filename string) ([]ComponentPath, error)
- func (rmfs *RootMappingFs) Stat(name string) (os.FileInfo, error)
- func (rmfs *RootMappingFs) UnwrapFilesystem() afero.Fs
- type WalkFn
- type Walkway
Constants ¶
This section is empty.
Variables ¶
var AppendDirsMerger overlayfs.DirsMerger = func(lofi, bofi []iofs.DirEntry) []iofs.DirEntry { for _, fi1 := range bofi { var found bool if fi1.IsDir() { for _, fi2 := range lofi { if fi2.IsDir() && fi2.Name() == fi1.Name() { found = true break } } } if !found { lofi = append(lofi, fi1) } } return lofi }
AppendDirsMerger merges two directories keeping all regular files with the first slice as the base. Duplicate directories in the second slice will be ignored. This strategy is used for the i18n and data fs where we need all entries.
var LanguageDirsMerger overlayfs.DirsMerger = func(lofi, bofi []iofs.DirEntry) []iofs.DirEntry { for _, fi1 := range bofi { var found bool for _, fi2 := range lofi { if fi1.Name() == fi2.Name() { found = true break } } if !found { lofi = append(lofi, fi1) } } return lofi }
LanguageDirsMerger implements the overlayfs.DirsMerger func, which is used to merge two directories.
var ( // NoOpFs provides a no-op filesystem that implements the afero.Fs // interface. NoOpFs = &noOpFs{} )
Functions ¶
func DirEntriesToFileMetaInfos ¶
func DirEntriesToFileMetaInfos(fis []iofs.DirEntry) []fs.FileMetaInfo
func GetVirtualFileInfo ¶
GetVirtualFileInfo returns the FileInfo of the virtual file
func Glob ¶
Glob walks the fs and passes all matches to the handle func. The handle func can return true to signal a stop.
func LstatIfPossible ¶
LstatIfPossible if the filesystem supports it, use Lstat, else use fs.Stat
func NewBasePathFs ¶
NewBasePathFs creates a new BasePathFs.
func NewHasBytesReceiver ¶
func NewHashingFs ¶
func NewHashingFs(delegate afero.Fs, hashReceiver FileHashReceiver) afero.Fs
NewHashingFs creates a new filesystem that will receive MD5 checksums of any written file content on Close. Note that this is probably not a good idea for "full build" situations, but when doing fast render mode, the amount of files published is low, and it would be really nice to know exactly which of these files where actually changed. Note that this will only work for file operations that use the io.Writer to write content to file, but that is fine for the "publish content" use case.
func NewReadOnlyFs ¶
NewReadOnlyFs creates a new ReadOnlyFs.
func RealFilename ¶
func RealFilename(cfs *ComponentFs, rel string) string
func WalkFilesystems ¶
WalkFilesystems walks fs recursively and calls fn. If fn returns true, walking is stopped.
Types ¶
type ComponentFs ¶
type ComponentFs struct { afero.Fs // The ComponentDir name, e.g. "content", "layouts" etc. Component string OverlayFs afero.Fs // contains filtered or unexported fields }
func NewComponentFs ¶
func NewComponentFs(component string, overlayFs *overlayfs.OverlayFs) *ComponentFs
func (*ComponentFs) MakePathRelative ¶
func (cfs *ComponentFs) MakePathRelative(filename string, checkExists bool) (string, bool)
MakePathRelative creates a relative path from the given filename.
func (*ComponentFs) RealDirs ¶
func (cfs *ComponentFs) RealDirs(from string) []string
RealDirs gets a list of absolute paths to directories starting from the given path.
func (*ComponentFs) ReverseLookup ¶
func (cfs *ComponentFs) ReverseLookup(filename string, checkExists bool) ([]ComponentPath, error)
ReverseLookup returns the ComponentDir paths for the given filename.
func (*ComponentFs) UnwrapFilesystem ¶
func (cfs *ComponentFs) UnwrapFilesystem() afero.Fs
type ComponentPath ¶
func (ComponentPath) ComponentPathJoined ¶
func (c ComponentPath) ComponentPathJoined() string
type ContentClass ¶
type ContentClass string
const ( ContentClassLeaf ContentClass = "leaf" ContentClassBranch ContentClass = "branch" ContentClassFile ContentClass = "zfile" // Sort below ContentClassContent ContentClass = "zcontent" )
type DirFile ¶
type DirFile struct { *File // contains filtered or unexported fields }
type FileChangeDetector ¶
type FileChangeDetector struct { sync.Mutex IrrelevantRe *regexp.Regexp // contains filtered or unexported fields }
func NewFileChangeDetector ¶
func NewFileChangeDetector() *FileChangeDetector
func (*FileChangeDetector) OnFileClose ¶
func (f *FileChangeDetector) OnFileClose(name, md5sum string)
func (*FileChangeDetector) PrepareNew ¶
func (f *FileChangeDetector) PrepareNew()
type FileHashReceiver ¶
type FileHashReceiver interface {
OnFileClose(name, md5sum string)
}
FileHashReceiver will receive the filename an the content's MD5 sum on file close.
type FileInfo ¶
func NewFileInfoWithName ¶
func NewFileInfoWithOpener ¶
func NewFileInfoWithOpener(fi os.FileInfo, filename string, opener FileOpener) *FileInfo
func NewFileInfoWithRoot ¶
func NewFileInfoWithRoot(fi os.FileInfo, filename, root string, opener FileOpener) *FileInfo
type FileMeta ¶
type FileMeta struct { ComponentRoot string ComponentDir string OpenFunc FileOpener // contains filtered or unexported fields }
func NewFileMeta ¶
func NewFileMeta() *FileMeta
func (*FileMeta) NormalizedFilename ¶
func (*FileMeta) RelativeFilename ¶
type FileOpener ¶
type FilesystemsCollector ¶
type FilesystemsCollector struct { SourceProject afero.Fs // Source for project folders SourceModules afero.Fs // Source for modules/themes OverlayMounts *overlayfs.OverlayFs OverlayMountsContent *overlayfs.OverlayFs OverlayMountsStatic *overlayfs.OverlayFs OverlayMountsFull *overlayfs.OverlayFs OverlayFull *overlayfs.OverlayFs OverlayResources *overlayfs.OverlayFs RootFss []*RootMappingFs AbsResourcesDir string }
type MetaProvider ¶
type MetaProvider interface {
Meta() *FileMeta
}
type ReverseLookupProvider ¶
type ReverseLookupProvider interface { ReverseLookup(filename string) ([]ComponentPath, error) ReverseLookupComponent(component, filename string) ([]ComponentPath, error) }
type RootMapping ¶
type RootMapping struct { // The virtual mount. From string FromBase string // The base directory of the virtual mount. //TODO // The source directory or file. To string ToBase string // The base of To. May be empty if an absolute path was provided. ToFi *FileInfo }
RootMapping describes a virtual file or directory mount.
func (RootMapping) Filename ¶
func (rm RootMapping) Filename(name string) string
type RootMappingFs ¶
func NewRootMappingFs ¶
func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error)
func (*RootMappingFs) Mounts ¶
func (rmfs *RootMappingFs) Mounts(base string) ([]fs.FileMetaInfo, error)
func (*RootMappingFs) Open ¶
func (rmfs *RootMappingFs) Open(name string) (afero.File, error)
Open opens the named file for reading.
func (*RootMappingFs) ReverseLookup ¶
func (rmfs *RootMappingFs) ReverseLookup(filename string) ([]ComponentPath, error)
func (*RootMappingFs) ReverseLookupComponent ¶
func (rmfs *RootMappingFs) ReverseLookupComponent(component, filename string) ([]ComponentPath, error)
func (*RootMappingFs) Stat ¶
func (rmfs *RootMappingFs) Stat(name string) (os.FileInfo, error)
Stat returns the os.FileInfo structure describing a given file. If there is an error, it will be of type *os.PathError.
func (*RootMappingFs) UnwrapFilesystem ¶
func (rmfs *RootMappingFs) UnwrapFilesystem() afero.Fs