streamwatcher/util.go
2020-10-25 11:42:56 +01:00

33 lines
674 B
Go

package main
import (
"log"
"os"
"path/filepath"
"strconv"
)
// FileExists returns true if path exists
func FileExists(path string) bool {
_, err := os.Stat(path)
return !os.IsNotExist(err)
}
// GetStreamDirPath returns filepath.Join(".", "streams")
func GetStreamDirPath() string {
return filepath.Join(".", "streams")
}
// StreamStorePathExists returns FileExists(GetStreamDirPath())
func StreamStorePathExists() bool {
return FileExists(GetStreamDirPath())
}
// StrToInt uses strconv.ParseInt
func StrToInt(str string) int {
i, err := strconv.ParseInt(str, 10, 64)
if err != nil {
log.Println("Could not convert string to int ", str)
}
return int(i)
}