aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Platform/Android/AdbClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/Platform/Android/AdbClient.cpp')
-rw-r--r--source/Plugins/Platform/Android/AdbClient.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/source/Plugins/Platform/Android/AdbClient.cpp b/source/Plugins/Platform/Android/AdbClient.cpp
index eb684ad0fbc0..2060bd1de735 100644
--- a/source/Plugins/Platform/Android/AdbClient.cpp
+++ b/source/Plugins/Platform/Android/AdbClient.cpp
@@ -15,15 +15,16 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileUtilities.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataEncoder.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/PosixApi.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataEncoder.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/Timeout.h"
#include <limits.h>
@@ -402,13 +403,14 @@ Error AdbClient::ShellToFile(const char *command, milliseconds timeout,
return error;
const auto output_filename = output_file_spec.GetPath();
- std::ofstream dst(output_filename, std::ios::out | std::ios::binary);
- if (!dst.is_open())
+ std::error_code EC;
+ llvm::raw_fd_ostream dst(output_filename, EC, llvm::sys::fs::F_None);
+ if (EC)
return Error("Unable to open local file %s", output_filename.c_str());
dst.write(&output_buffer[0], output_buffer.size());
dst.close();
- if (!dst)
+ if (dst.has_error())
return Error("Failed to write file %s", output_filename.c_str());
return Error();
}
@@ -428,8 +430,9 @@ Error AdbClient::SyncService::internalPullFile(const FileSpec &remote_file,
const auto local_file_path = local_file.GetPath();
llvm::FileRemover local_file_remover(local_file_path);
- std::ofstream dst(local_file_path, std::ios::out | std::ios::binary);
- if (!dst.is_open())
+ std::error_code EC;
+ llvm::raw_fd_ostream dst(local_file_path, EC, llvm::sys::fs::F_None);
+ if (EC)
return Error("Unable to open local file %s", local_file_path.c_str());
const auto remote_file_path = remote_file.GetPath(false);
@@ -447,6 +450,9 @@ Error AdbClient::SyncService::internalPullFile(const FileSpec &remote_file,
if (!eof)
dst.write(&chunk[0], chunk.size());
}
+ dst.close();
+ if (dst.has_error())
+ return Error("Failed to write file %s", local_file_path.c_str());
local_file_remover.releaseFile();
return error;