@marcel91200 / caddy Mirror · read-only
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 01:00 UTC

master
go 29 lines 1.01 KB
Raw
1 package filesystems
2
3 import (
4 "io/fs"
5 "os"
6 "path/filepath"
7 )
8
9 // OsFS is a simple fs.FS implementation that uses the local
10 // file system. (We do not use os.DirFS because we do our own
11 // rooting or path prefixing without being constrained to a single
12 // root folder. The standard os.DirFS implementation is problematic
13 // since roots can be dynamic in our application.)
14 //
15 // OsFS also implements fs.StatFS, fs.GlobFS, fs.ReadDirFS, and fs.ReadFileFS.
16 type OsFS struct{}
17
18 func (OsFS) Open(name string) (fs.File, error) { return os.Open(name) }
19 func (OsFS) Stat(name string) (fs.FileInfo, error) { return os.Stat(name) }
20 func (OsFS) Glob(pattern string) ([]string, error) { return filepath.Glob(pattern) }
21 func (OsFS) ReadDir(name string) ([]fs.DirEntry, error) { return os.ReadDir(name) }
22 func (OsFS) ReadFile(name string) ([]byte, error) { return os.ReadFile(name) }
23
24 var (
25 _ fs.StatFS = (*OsFS)(nil)
26 _ fs.GlobFS = (*OsFS)(nil)
27 _ fs.ReadDirFS = (*OsFS)(nil)
28 _ fs.ReadFileFS = (*OsFS)(nil)
29 )