1package vfsutil
2
3import (
4 "net/http"
5 "os"
6)
7
8// File implements http.FileSystem using the native file system restricted to a
9// specific file served at root.
10//
11// While the FileSystem.Open method takes '/'-separated paths, a File's string
12// value is a filename on the native file system, not a URL, so it is separated
13// by filepath.Separator, which isn't necessarily '/'.
14type File string
15
16func (f File) Open(name string) (http.File, error) {
17 if name != "/" {
18 return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
19 }
20 return os.Open(string(f))
21}