35 lines
743 B
Go
35 lines
743 B
Go
package metadata
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/BurntSushi/toml"
|
|
)
|
|
|
|
// Load attempts to read a FyneApp metadata from the provided reader.
|
|
// If this cannot be done an error will be returned.
|
|
func Load(r io.Reader) (*FyneApp, error) {
|
|
var data FyneApp
|
|
_, err := toml.NewDecoder(r).Decode(&data)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &data, nil
|
|
}
|
|
|
|
// LoadStandard attempts to read a FyneApp metadata from the `FyneApp.toml` file in the specified dir.
|
|
// If the file cannot be found or parsed an error will be returned.
|
|
func LoadStandard(dir string) (*FyneApp, error) {
|
|
path := filepath.Join(dir, "FyneApp.toml")
|
|
r, err := os.Open(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
defer r.Close()
|
|
return Load(r)
|
|
}
|