settings: Rename struct to remove FIC occurence

This commit is contained in:
nemunaire 2022-05-01 22:15:16 +02:00
commit e8f6a03cd9
6 changed files with 13 additions and 13 deletions

View file

@ -20,8 +20,8 @@ const SettingsFile = "settings.json"
// SettingsDir is the relative location where the SettingsFile lies.
var SettingsDir string = "./SETTINGS"
// FICSettings represents the settings panel.
type FICSettings struct {
// Settings represents the settings panel.
type Settings struct {
// Title is the displayed name of the challenge.
Title string `json:"title"`
// Authors is the group name of people making the challenge.
@ -92,8 +92,8 @@ func ExistsSettings(settingsPath string) bool {
}
// ReadSettings parses the file at the given location.
func ReadSettings(path string) (*FICSettings, error) {
var s FICSettings
func ReadSettings(path string) (*Settings, error) {
var s Settings
if fd, err := os.Open(path); err != nil {
return nil, err
} else {
@ -109,7 +109,7 @@ func ReadSettings(path string) (*FICSettings, error) {
}
// SaveSettings saves settings at the given location.
func SaveSettings(path string, s *FICSettings) error {
func SaveSettings(path string, s *Settings) error {
if fd, err := os.Create(path); err != nil {
return err
} else {
@ -139,7 +139,7 @@ func ForceRegeneration() error {
// Giving the location and a callback, this function will first call your reload function
// before returning (if the file can be parsed); then it starts watching modifications made to
// this file. Your callback is then run each time the file is modified.
func LoadAndWatchSettings(settingsPath string, reload func(*FICSettings)) {
func LoadAndWatchSettings(settingsPath string, reload func(*Settings)) {
// First load of configuration if it exists
if _, err := os.Stat(settingsPath); !os.IsNotExist(err) {
if config, err := ReadSettings(settingsPath); err != nil {
@ -184,7 +184,7 @@ func LoadAndWatchSettings(settingsPath string, reload func(*FICSettings)) {
}
}
func tryReload(settingsPath string, reload func(*FICSettings)) {
func tryReload(settingsPath string, reload func(*Settings)) {
if config, err := ReadSettings(settingsPath); err != nil {
log.Println("ERROR: Unable to read challenge settings:", err)
} else if time.Until(config.ActivateTime) > 0 {