2020-05-30 04:08:33 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
2020-06-02 03:42:36 +03:00
|
|
|
"path/filepath"
|
2020-05-30 04:08:33 +03:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func resetDirectories() {
|
|
|
|
os.RemoveAll("hls")
|
|
|
|
os.MkdirAll("hls", 0777)
|
|
|
|
}
|
|
|
|
|
|
|
|
func touch(fileName string) {
|
|
|
|
_, err := os.Stat(fileName)
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
file, err := os.Create("temp.txt")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
} else {
|
|
|
|
currentTime := time.Now().Local()
|
|
|
|
err = os.Chtimes(fileName, currentTime, currentTime)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-02 03:42:36 +03:00
|
|
|
func getTempPipePath() string {
|
|
|
|
return filepath.Join(os.TempDir(), "streampipe.flv")
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:08:33 +03:00
|
|
|
func copy(src, dst string) {
|
|
|
|
input, err := ioutil.ReadFile(src)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ioutil.WriteFile(dst, input, 0644)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error creating", dst)
|
|
|
|
fmt.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2020-06-02 02:53:31 +03:00
|
|
|
|
|
|
|
func fileExists(name string) bool {
|
|
|
|
if _, err := os.Stat(name); err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|