...

Source file src/github.com/shurcooL/httpfs/vfsutil/file.go

Documentation: github.com/shurcooL/httpfs/vfsutil

     1  package vfsutil
     2  
     3  import (
     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 '/'.
    14  type File string
    15  
    16  func (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  }
    22  

View as plain text