2020-05-08 14:37:43 +00:00
|
|
|
package distribyted
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type binaryFileSystem struct {
|
|
|
|
http.FileSystem
|
|
|
|
}
|
|
|
|
|
2020-05-18 17:42:23 +00:00
|
|
|
func NewBinaryFileSystem(fs http.FileSystem) *binaryFileSystem {
|
|
|
|
return &binaryFileSystem{fs}
|
2020-05-08 14:37:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *binaryFileSystem) Exists(prefix string, filepath string) bool {
|
|
|
|
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
|
|
|
|
if _, err := fs.Open(p); err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|