-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfs.go
38 lines (24 loc) · 926 Bytes
/
fs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package kipp
import (
"net/http"
"os"
"time"
"github.com/uhthomas/kipp/database"
"github.com/uhthomas/kipp/filesystem"
)
// fileSystemFunc implements http.FileSystem.
type fileSystemFunc func(string) (http.File, error)
func (f fileSystemFunc) Open(name string) (http.File, error) { return f(name) }
type file struct {
filesystem.Reader
entry database.Entry
}
func (f *file) Readdir(int) ([]os.FileInfo, error) { return nil, nil }
func (f *file) Stat() (os.FileInfo, error) { return &fileInfo{entry: f.entry}, nil }
type fileInfo struct{ entry database.Entry }
func (fi *fileInfo) Name() string { return fi.entry.Name }
func (fi *fileInfo) Size() int64 { return fi.entry.Size }
func (fi *fileInfo) Mode() os.FileMode { return 0600 }
func (fi *fileInfo) IsDir() bool { return false }
func (fi *fileInfo) Sys() interface{} { return nil }
func (fi *fileInfo) ModTime() time.Time { return fi.entry.Timestamp }