PKGBUILD/pkg/sensor/sensor.go

29 lines
575 B
Go
Raw Normal View History

package sensor
import (
"os"
"path/filepath"
2018-11-21 19:48:10 +00:00
"git.cryptic.systems/fh-trier/go-flucky/pkg/types"
)
2018-11-21 19:48:10 +00:00
// Exists returns a boolean if the sensor exists
func Exists(wirePath, sensorID string) bool {
sensorPath := filepath.Join(wirePath, sensorID)
if _, err := os.Stat(sensorPath); os.IsNotExist(err) {
return false
}
return true
}
2018-11-21 19:48:10 +00:00
// IsRedundant returns a boolean if the sensorID is in the array
func IsRedundant(sensorID string, sensors []*types.WireSensor) bool {
for _, sensor := range sensors {
if sensor.ID == sensorID {
return true
}
}
return false
}