2021-12-24 01:14:18 +00:00
|
|
|
package neutered_filesystem
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type NeuteredFileSystem struct {
|
|
|
|
fs http.FileSystem
|
|
|
|
}
|
|
|
|
|
2021-12-24 01:17:44 +00:00
|
|
|
func New(fs http.FileSystem) NeuteredFileSystem {
|
|
|
|
return NeuteredFileSystem{fs}
|
|
|
|
}
|
|
|
|
|
2021-12-24 01:14:18 +00:00
|
|
|
func (fs NeuteredFileSystem) Open(name string) (http.File, error) {
|
|
|
|
f, err := fs.fs.Open(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return neuteredReaddirFile{f}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type neuteredReaddirFile struct {
|
|
|
|
http.File
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|