Add a flag to FileOutputBuffer that allows modification.
authorZachary Turner <zturner@google.com>
Thu, 28 Jun 2018 18:49:09 +0000 (18:49 +0000)
committerZachary Turner <zturner@google.com>
Thu, 28 Jun 2018 18:49:09 +0000 (18:49 +0000)
commit1adca7c4a5119fb79757a5a9635c9e01ec996ced
treee1f12ba1e6575501af5af7abccb1e285e08aad3d
parentc09b5e31d778ad6cb96b5cbc8d1153e5b9b23cf8
Add a flag to FileOutputBuffer that allows modification.

FileOutputBuffer creates a temp file and on commit atomically
renames the temp file to the destination file.  Sometimes we
want to modify an existing file in place, but still have the
atomicity guarantee.  To do this we can initialize the contents
of the temp file from the destination file (if it exists), that
way the resulting FileOutputBuffer can have only selective
bytes modified.  Committing will then atomically replace the
destination file as desired.

llvm-svn: 335902
llvm/include/llvm/Support/FileOutputBuffer.h
llvm/include/llvm/Support/FileSystem.h
llvm/lib/Support/FileOutputBuffer.cpp
llvm/lib/Support/Path.cpp
llvm/unittests/Support/FileOutputBufferTest.cpp