2020-09-05 03:28:01 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func WriteFile(destinationPath string, tempPath string, dataForDisk []byte) {
|
2020-09-20 23:28:48 +00:00
|
|
|
if err := ioutil.WriteFile(tempPath, dataForDisk, 0644); err != nil {
|
2020-09-05 03:28:01 +00:00
|
|
|
log.Fatalf("Error writing temp file : %s", err)
|
|
|
|
}
|
|
|
|
if err := os.Rename(tempPath, destinationPath); err != nil {
|
|
|
|
log.Fatalf("Error moving new in place : %s", err)
|
|
|
|
}
|
|
|
|
}
|