filterfs

package
v1.5.54 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package filterfs provides a wrapper around an fs.FS that only presents regular files and directories to the user.

This wrapper has some overhead, as it attempts to open files to ensure that "invisible" permissions (SELinux, etc.) are also valid.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirFile

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

DirFile is a ReadDirFile wrapper for fs.File.

func (*DirFile) Close

func (d *DirFile) Close() error

func (*DirFile) Read

func (d *DirFile) Read(_ []byte) (int, error)

func (*DirFile) ReadDir

func (d *DirFile) ReadDir(n int) ([]fs.DirEntry, error)

func (*DirFile) Stat

func (d *DirFile) Stat() (fs.FileInfo, error)

type FS

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

FS wraps an fs.FS and hides inaccessible files and directories by returning appropriate "not found" errors or filtering them from listings.

func New

func New(fsys fs.FS) *FS

New creates a new FS wrapper around the provided filesystem.

func (*FS) Open

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

Open opens the named file for reading and if file is a directory wraps it with a ReadFileDir instance that filters out access errors

func (*FS) ReadDir

func (f *FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads and returns directory entries, filtering out inaccessible items.

Jump to

Keyboard shortcuts

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