本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
571B

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