This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Writing files atomically is very important. Unfortunately, it seems atomic rename is not available on Windows, so this feature is Unix-only.
- Loading branch information
Showing
4 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// +build !windows | ||
|
||
package fsutil | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/google/renameio" | ||
) | ||
|
||
// WriteFile writes data to filename atomically with permission perm. | ||
func (OSDriver) WriteFile(filename string, data []byte, perm os.FileMode) error { | ||
return renameio.WriteFile(filename, data, perm) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// +build windows | ||
|
||
package fsutil | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
// WriteFile writes data to filename with permission perm. | ||
func (OSDriver) WriteFile(filename string, data []byte, perm os.FileMode) error { | ||
return ioutil.WriteFile(filename, data, perm) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters