35 lines
781 B
Go
35 lines
781 B
Go
|
package ui
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
var _ Resources = &OSResources{}
|
||
|
|
||
|
// DefaultResources returns the default Resources implementation (OSResources).
|
||
|
func DefaultResources() Resources {
|
||
|
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 }
|