a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
32 lines
739 B
Go
32 lines
739 B
Go
//go:build windows
|
|
// +build windows
|
|
|
|
// This file is NOT part of upstream github.com/google/renameio v1.0.1,
|
|
// which builds only on non-Windows platforms. It was added by the
|
|
// Gortex project. See README.md in this directory.
|
|
|
|
package renameio
|
|
|
|
import "os"
|
|
|
|
// WriteFile mirrors os.WriteFile, replacing an existing file with the
|
|
// same name atomically.
|
|
func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
|
t, err := TempFile("", filename)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer t.Cleanup()
|
|
|
|
// Set permissions before writing data, in case the data is sensitive.
|
|
if err := t.Chmod(perm); err != nil {
|
|
return err
|
|
}
|
|
|
|
if _, err := t.Write(data); err != nil {
|
|
return err
|
|
}
|
|
|
|
return t.CloseAtomicallyReplace()
|
|
}
|