Initial POC works with IPFS

This commit is contained in:
Gabe Kangas
2020-05-29 18:08:33 -07:00
parent cc48f86b85
commit af698063bd
40 changed files with 826 additions and 29 deletions

46
utils.go Normal file
View File

@@ -0,0 +1,46 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"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 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
}
}