llvm_tools: Add atomic_write to patch_utils.py

This allows a utility function which can write to an
arbitrary file without risking an incomplete write error,
causing issues and creating an invalid edit.

This function ensures that the file is only swapped if the
file write was successful, otherwise the file is deleted.

BUG=None
TEST=./patch_utils_unittest.py

Change-Id: Iedc3297b0e59d216f027e6ff125f92bc4d088c7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3685569
Reviewed-by: George Burgess <gbiv@chromium.org>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
2 files changed