zntg/ui/osresources.go

35 lines
797 B
Go
Raw Permalink Normal View History

2020-05-15 12:20:07 +00:00
package ui
import (
"io"
"os"
)
var _ PhysicalResources = &OSResources{}
2020-05-15 12:20:07 +00:00
// DefaultResources returns the default Resources implementation (OSResources).
func DefaultResources() PhysicalResources {
2020-05-15 12:20:07 +00:00
return &OSResources{}
}
// OSResources is Resources implementation that uses the default file system directly.
type OSResources struct {
}
// FetchResource checks if file is available and returns the specified path.
func (r *OSResources) FetchResource(name string) (string, error) {
_, err := os.Stat(name)
if err != nil {
return "", err
}
return name, nil
}
// OpenResource opens the specified file on disk.
func (r *OSResources) OpenResource(name string) (io.ReadCloser, error) {
return os.Open(name)
}
// Destroy does nothing.
func (r *OSResources) Destroy() error { return nil }