diff options
| author | Greg Clayton <gclayton@apple.com> | 2014-09-18 00:16:13 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2014-09-18 00:16:13 +0000 |
| commit | 90d9a35ff11950a112576f48917353a1bd42187a (patch) | |
| tree | 5138ebcbf0b212db93af60b17d4b2b9dc23f1182 | |
| parent | 56bf559253ee216cc3b209809b05868186ae87e9 (diff) | |
| download | bcm5719-llvm-90d9a35ff11950a112576f48917353a1bd42187a.tar.gz bcm5719-llvm-90d9a35ff11950a112576f48917353a1bd42187a.zip | |
Listen to the return value of the Platform::WriteFile() call within PlatformPOSIX::PutFile() in case we write less than we wanted to. Also adjust the input stream's offset in such cases.
llvm-svn: 217999
| -rw-r--r-- | lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index cc4c693e1b4..05e673f3296 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -330,8 +330,14 @@ PlatformPOSIX::PutFile (const lldb_private::FileSpec& source, error = source_file.Read(buffer_sp->GetBytes(), bytes_read); if (bytes_read) { - WriteFile(dest_file, offset, buffer_sp->GetBytes(), bytes_read, error); - offset += bytes_read; + const uint64_t bytes_written = WriteFile(dest_file, offset, buffer_sp->GetBytes(), bytes_read, error); + offset += bytes_written; + if (bytes_written != bytes_read) + { + // We didn't write the correct numbe of bytes, so adjust + // the file position in the source file we are reading from... + source_file.SeekFromStart(offset); + } } else break; @@ -343,6 +349,18 @@ PlatformPOSIX::PutFile (const lldb_private::FileSpec& source, // std::string dst_path (destination.GetPath()); // if (chown_file(this,dst_path.c_str(),uid,gid) != 0) // return Error("unable to perform chown"); + + + uint64_t src_md5[2]; + uint64_t dst_md5[2]; + + if (FileSystem::CalculateMD5 (source, src_md5[0], src_md5[1]) && CalculateMD5 (destination, dst_md5[0], dst_md5[1])) + { + if (src_md5[0] != dst_md5[0] || src_md5[1] != dst_md5[1]) + { + error.SetErrorString("md5 checksum of installed file doesn't match, installation failed"); + } + } return error; } return Platform::PutFile(source,destination,uid,gid); |

