[llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place.
The restoreDateOnFile() method used to preserve dates uses sys::fs::openFileForWrite(). That method defaults to opening files with CD_CreateAlways, which truncates the output file if it exists. Use CD_OpenExisting instead to open it and *not* truncate it, which also has the side benefit of erroring if the file does not exist (it should always exist, because we just wrote it out). Also, fix the test case to make sure the output is a valid output file, and not empty. The extra test assertions are enough to catch this regression. llvm-svn: 340996
Loading
Please register or sign in to comment