mirror of https://github.com/hrfee/jfa-go
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.
31 lines
476 B
31 lines
476 B
package main
|
|
|
|
import (
|
|
"io/fs"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
type httpFS struct {
|
|
hfs http.FileSystem
|
|
fs fs.FS
|
|
}
|
|
|
|
func (f httpFS) Open(name string) (http.File, error) {
|
|
return f.hfs.Open(name)
|
|
}
|
|
|
|
func (f httpFS) Exists(prefix string, filepath string) bool {
|
|
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
|
|
stats, err := fs.Stat(f.fs, p)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if stats.IsDir() {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}
|