1package rice
2
3import (
4	"os"
5	"time"
6
7	"github.com/GeertJohan/go.rice/embedded"
8)
9
10// re-type to make exported methods invisible to user (godoc)
11// they're not required for the user
12// embeddedDirInfo implements os.FileInfo
13type embeddedDirInfo embedded.EmbeddedDir
14
15// Name returns the base name of the directory
16// (implementing os.FileInfo)
17func (ed *embeddedDirInfo) Name() string {
18	return ed.Filename
19}
20
21// Size always returns 0
22// (implementing os.FileInfo)
23func (ed *embeddedDirInfo) Size() int64 {
24	return 0
25}
26
27// Mode returns the file mode bits
28// (implementing os.FileInfo)
29func (ed *embeddedDirInfo) Mode() os.FileMode {
30	return os.FileMode(0555 | os.ModeDir) // dr-xr-xr-x
31}
32
33// ModTime returns the modification time
34// (implementing os.FileInfo)
35func (ed *embeddedDirInfo) ModTime() time.Time {
36	return ed.DirModTime
37}
38
39// IsDir returns the abbreviation for Mode().IsDir() (always true)
40// (implementing os.FileInfo)
41func (ed *embeddedDirInfo) IsDir() bool {
42	return true
43}
44
45// Sys returns the underlying data source (always nil)
46// (implementing os.FileInfo)
47func (ed *embeddedDirInfo) Sys() interface{} {
48	return nil
49}
50
51// re-type to make exported methods invisible to user (godoc)
52// they're not required for the user
53// embeddedFileInfo implements os.FileInfo
54type embeddedFileInfo embedded.EmbeddedFile
55
56// Name returns the base name of the file
57// (implementing os.FileInfo)
58func (ef *embeddedFileInfo) Name() string {
59	return ef.Filename
60}
61
62// Size returns the length in bytes for regular files; system-dependent for others
63// (implementing os.FileInfo)
64func (ef *embeddedFileInfo) Size() int64 {
65	return int64(len(ef.Content))
66}
67
68// Mode returns the file mode bits
69// (implementing os.FileInfo)
70func (ef *embeddedFileInfo) Mode() os.FileMode {
71	return os.FileMode(0555) // r-xr-xr-x
72}
73
74// ModTime returns the modification time
75// (implementing os.FileInfo)
76func (ef *embeddedFileInfo) ModTime() time.Time {
77	return ef.FileModTime
78}
79
80// IsDir returns the abbreviation for Mode().IsDir() (always false)
81// (implementing os.FileInfo)
82func (ef *embeddedFileInfo) IsDir() bool {
83	return false
84}
85
86// Sys returns the underlying data source (always nil)
87// (implementing os.FileInfo)
88func (ef *embeddedFileInfo) Sys() interface{} {
89	return nil
90}
91