mirror of
https://github.com/pikami/tiktok-dl.git
synced 2024-11-25 09:15:41 +00:00
33 lines
599 B
Go
33 lines
599 B
Go
package utils
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
)
|
|
|
|
// CheckIfExists - Checks if file or directory exists
|
|
func CheckIfExists(path string) bool {
|
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// InitOutputDirectory - Creates output directory
|
|
func InitOutputDirectory(path string) {
|
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
os.MkdirAll(path, os.ModePerm)
|
|
}
|
|
}
|
|
|
|
// ReadFileToString - Reads file and returns content
|
|
func ReadFileToString(path string) string {
|
|
content, err := ioutil.ReadFile(path)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return string(content)
|
|
}
|