mirror of
https://github.com/owncast/owncast.git
synced 2024-11-22 04:40:37 +03:00
60 lines
966 B
Go
60 lines
966 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
"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)
|
|
}
|
|
}
|
|
}
|
|
|
|
func getTempPipePath() string {
|
|
return filepath.Join(os.TempDir(), "streampipe.flv")
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
func fileExists(name string) bool {
|
|
if _, err := os.Stat(name); err != nil {
|
|
if os.IsNotExist(err) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|