2020-10-22 06:47:42 +02:00
|
|
|
package config
|
2020-06-23 03:11:56 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2020-11-13 00:14:59 +01:00
|
|
|
// verifyFFMpegPath verifies that the path exists, is a file, and is executable.
|
2020-10-22 06:47:42 +02:00
|
|
|
func verifyFFMpegPath(path string) error {
|
2020-06-23 03:11:56 +02:00
|
|
|
stat, err := os.Stat(path)
|
|
|
|
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return errors.New("ffmpeg path does not exist")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("error while verifying the ffmpeg path: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if stat.IsDir() {
|
|
|
|
return errors.New("ffmpeg path can not be a folder")
|
|
|
|
}
|
|
|
|
|
|
|
|
mode := stat.Mode()
|
|
|
|
//source: https://stackoverflow.com/a/60128480
|
|
|
|
if mode&0111 == 0 {
|
|
|
|
return errors.New("ffmpeg path is not executable")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|