wails-app-dock/pkg/utils/resources/relativefs.go
2024-02-17 21:45:43 +08:00

28 lines
467 B
Go

package resources
import (
"embed"
"io/fs"
"path"
)
type RelativeFS struct {
Fs embed.FS
Root string
}
func (r *RelativeFS) Open(name string) (fs.File, error) {
p := path.Join(r.Root, name)
return r.Fs.Open(p)
}
func (r *RelativeFS) ReadDir(name string) ([]fs.DirEntry, error) {
p := path.Join(r.Root, name)
return r.Fs.ReadDir(p)
}
func (r *RelativeFS) ReadFile(name string) ([]byte, error) {
p := path.Join(r.Root, name)
return r.Fs.ReadFile(p)
}