diff options
author | Oleksiy Vyalov <ovyalov@google.com> | 2015-02-05 16:29:12 +0000 |
---|---|---|
committer | Oleksiy Vyalov <ovyalov@google.com> | 2015-02-05 16:29:12 +0000 |
commit | 4536c458e1d9eb650a8bb487d82280afac64f4f1 (patch) | |
tree | 01c31ba537a11f2bd521e93335802c653424989e /lldb/source/Host/windows/PipeWindows.cpp | |
parent | 72b3b62fac3fbe0c5eb84974495014c4e8d322ee (diff) | |
download | bcm5719-llvm-4536c458e1d9eb650a8bb487d82280afac64f4f1.tar.gz bcm5719-llvm-4536c458e1d9eb650a8bb487d82280afac64f4f1.zip |
Fix warning about the use of mktemp and make platform agnostic by adding and using PipeBase::CreateWithUniqueName - on behalf of flackr.
http://reviews.llvm.org/D7348
llvm-svn: 228307
Diffstat (limited to 'lldb/source/Host/windows/PipeWindows.cpp')
-rw-r--r-- | lldb/source/Host/windows/PipeWindows.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index 852630eb04b..eccc73810f3 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -9,6 +9,8 @@ #include "lldb/Host/windows/PipeWindows.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" #include <fcntl.h> @@ -90,6 +92,24 @@ PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit) } Error +PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name) +{ + llvm::SmallString<128> pipe_name; + Error error; + do { + pipe_name = prefix; + pipe_name += "-"; + for (unsigned i = 0; i < 6; i++) { + pipe_name += "0123456789abcdef"[llvm::sys::Process::GetRandomNumber() & 15]; + } + Error error = CreateNew(pipe_name, child_process_inherit); + } while (error.GetError() == ERROR_ALREADY_EXISTS); + if (error.Success()) + name = pipe_name; + return error; +} + +Error PipeWindows::OpenAsReader(llvm::StringRef name, bool child_process_inherit) { if (CanRead() || CanWrite()) |