|
|
@ -12,6 +12,7 @@ import (
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// WriteFile writes data to filename+some suffix, then renames it
|
|
|
|
// WriteFile writes data to filename+some suffix, then renames it
|
|
|
@ -31,8 +32,10 @@ func WriteFile(filename string, data []byte, perm os.FileMode) (err error) {
|
|
|
|
if _, err := f.Write(data); err != nil {
|
|
|
|
if _, err := f.Write(data); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := f.Chmod(perm); err != nil {
|
|
|
|
if runtime.GOOS != "windows" {
|
|
|
|
return err
|
|
|
|
if err := f.Chmod(perm); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := f.Sync(); err != nil {
|
|
|
|
if err := f.Sync(); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|