The original motivation for this came from D25712, in which Eugene pointed out that File::Read() does not correctly handle short reads. However, I felt the fix was incomplete because it left the bug in other functions, and the code in general could have used some cleanup since there was a ton of duplication, which may be what led to this bug showing up in the first place.
Changes in this patch are:
- Have the normal Read() and Write() functions delegate to the versions that read and write with offset.
- Supply thread-safe versions of the Windows codepaths, which were previously incorrect in a multi-threaded environment.
- Delete a bunch of dead functions that are not used anywhere in LLDB.
- Remove the apple specific path due to MAX_READ_SIZE and MAX_WRITE_SIZE and merge with the standard non-Windows path.
The only real tricky part about this patch was that when you open a file in append mode, the old version of Write() with no offset would write at the end, whereas pwrite() always writes at the offset you specify. So to fix this I made the version of Write() with no offset explicitly compute the offset of the end of the file and pass that to the offset-version of Write().