mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 01:11:10 -06:00
55e6f64977
This originated in the cliconfig code to write out credentials files. The Windows implementation of this in particular was quite onerous to get right because it needs a very specific sequence of operations to avoid running into exclusive file locks, and so by factoring this out with only cosmetic modification we can avoid repeating all of that engineering effort for other atomic file writing use-cases.
13 lines
609 B
Go
13 lines
609 B
Go
// Package replacefile is a small helper package focused directly at the
|
|
// problem of atomically "renaming" one file over another one.
|
|
//
|
|
// On Unix systems this is the standard behavior of the rename function, but
|
|
// the equivalent operation on Windows requires some specific operation flags
|
|
// which this package encapsulates.
|
|
//
|
|
// This package uses conditional compilation to select a different
|
|
// implementation for Windows vs. all other platforms. It may therefore
|
|
// require further fiddling in future if Terraform is ported to another
|
|
// OS that is neither Unix-like nor Windows.
|
|
package replacefile
|