[Lldb-commits] [lldb] r217999 - 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.
Greg Clayton
gclayton at apple.com
Wed Sep 17 17:16:13 PDT 2014
Author: gclayton
Date: Wed Sep 17 19:16:13 2014
New Revision: 217999
URL: http://llvm.org/viewvc/llvm-project?rev=217999&view=rev
Log:
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.
Modified:
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=217999&r1=217998&r2=217999&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Wed Sep 17 19:16:13 2014
@@ -330,8 +330,14 @@ PlatformPOSIX::PutFile (const lldb_priva
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_priva
// 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);
More information about the lldb-commits
mailing list