...
1 package module
2
3 import (
4 "io/fs"
5 "os"
6 )
7
8
9 type SourceLoc struct {
10
11 FS fs.FS
12
13 Dir string
14 }
15
16
17
18
19 type OSRootFS interface {
20 fs.FS
21
22
23
24
25 OSRoot() string
26 }
27
28
29
30 func OSDirFS(p string) fs.FS {
31 return dirFSImpl{
32 augmentedFS: os.DirFS(p).(augmentedFS),
33 osRoot: p,
34 }
35 }
36
37 var _ interface {
38 augmentedFS
39 OSRootFS
40 } = dirFSImpl{}
41
42 type augmentedFS interface {
43 fs.FS
44 fs.StatFS
45 fs.ReadDirFS
46 fs.ReadFileFS
47 }
48
49 type dirFSImpl struct {
50 osRoot string
51 augmentedFS
52 }
53
54 func (fsys dirFSImpl) OSRoot() string {
55 return fsys.osRoot
56 }
57
View as plain text