2021-03-17 08:47:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-03-17 13:45:54 +00:00
|
|
|
func createIniFile(fpath string) []error {
|
2021-03-17 08:47:51 +00:00
|
|
|
log.Printf("Creating config file: %s\n", fpath)
|
2021-03-17 13:45:54 +00:00
|
|
|
var errorlist []error
|
2021-03-17 08:47:51 +00:00
|
|
|
if err := os.MkdirAll(filepath.Dir(fpath), 0770); err != nil {
|
2021-03-17 13:45:54 +00:00
|
|
|
errorlist = append(errorlist, err)
|
2021-03-17 08:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file, err := os.Create(fpath)
|
|
|
|
if err != nil {
|
2021-03-17 13:45:54 +00:00
|
|
|
errorlist = append(errorlist, err)
|
2021-03-17 08:47:51 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 13:45:54 +00:00
|
|
|
if _, err := file.Write([]byte("[DEFAULT]\n")); err != nil {
|
|
|
|
errorlist = append(errorlist, err)
|
|
|
|
}
|
|
|
|
if _, err := file.Write([]byte("radio_browser.api=all.api.radio-browser.info\n")); err != nil {
|
|
|
|
errorlist = append(errorlist, err)
|
|
|
|
}
|
|
|
|
if _, err := file.Write([]byte("player.command=mpv\n")); err != nil {
|
|
|
|
errorlist = append(errorlist, err)
|
|
|
|
}
|
|
|
|
if _, err := file.Write([]byte("player.options=--no-video\n")); err != nil {
|
|
|
|
errorlist = append(errorlist, err)
|
|
|
|
}
|
|
|
|
if _, err := file.Write([]byte("menu_items.max=9999\n")); err != nil {
|
|
|
|
errorlist = append(errorlist, err)
|
|
|
|
}
|
2021-03-17 08:47:51 +00:00
|
|
|
|
2021-03-17 13:45:54 +00:00
|
|
|
defer func() {
|
|
|
|
err := file.Close()
|
|
|
|
if err != nil {
|
|
|
|
errorlist = append(errorlist, err)
|
|
|
|
}
|
|
|
|
}()
|
2021-03-17 08:47:51 +00:00
|
|
|
|
2021-03-17 13:45:54 +00:00
|
|
|
return errorlist
|
2021-03-17 08:47:51 +00:00
|
|
|
}
|