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)
}
