1package goose
2
3import (
4 "io/fs"
5 "os"
6 "path/filepath"
7)
8
9// osFS wraps functions working with os filesystem to implement fs.FS interfaces.
10type osFS struct{}
11
12func (osFS) Open(name string) (fs.File, error) { return os.Open(filepath.FromSlash(name)) }
13
14func (osFS) ReadDir(name string) ([]fs.DirEntry, error) { return os.ReadDir(filepath.FromSlash(name)) }
15
16func (osFS) Stat(name string) (fs.FileInfo, error) { return os.Stat(filepath.FromSlash(name)) }
17
18func (osFS) ReadFile(name string) ([]byte, error) { return os.ReadFile(filepath.FromSlash(name)) }
19
20func (osFS) Glob(pattern string) ([]string, error) { return filepath.Glob(filepath.FromSlash(pattern)) }
21
22type noopFS struct{}
23
24var _ fs.FS = noopFS{}
25
26func (f noopFS) Open(name string) (fs.File, error) {
27 return nil, os.ErrNotExist
28}