mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-23 11:27:25 +08:00
43 lines
830 B
Go
43 lines
830 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// HasConfigFiles checks if a directory contains both config.yml and keys.yml files
|
|
func HasConfigFiles(dirPath string) bool {
|
|
configPath := filepath.Join(dirPath, "config.yml")
|
|
keysPath := filepath.Join(dirPath, "keys.yml")
|
|
|
|
// Check if both files exist
|
|
configExists := false
|
|
keysExists := false
|
|
|
|
if _, err := os.Stat(configPath); !os.IsNotExist(err) {
|
|
configExists = true
|
|
}
|
|
|
|
if _, err := os.Stat(keysPath); !os.IsNotExist(err) {
|
|
keysExists = true
|
|
}
|
|
|
|
return configExists && keysExists
|
|
}
|
|
|
|
func ListConfigurations() ([]string, error) {
|
|
files, err := os.ReadDir(ConfigDirs)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
configs := make([]string, 0)
|
|
for _, file := range files {
|
|
if file.IsDir() {
|
|
configs = append(configs, file.Name())
|
|
}
|
|
}
|
|
|
|
return configs, nil
|
|
}
|