Use Host::File in lldb_private::StreamFile and other places to cleanup host
layer a bit more.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125149 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index c706bb5..0024e6d 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -418,28 +418,25 @@
     size_t bytes_len
 )
 {
-    FILE *out_fh = reader.GetDebugger().GetOutputFileHandle();
+    File &out_file = reader.GetDebugger().GetOutputFile();
 
     switch (notification)
     {
     case eInputReaderActivate:
-        if (out_fh)
-        {
-            ::fprintf (out_fh, "%s\n", g_reader_instructions);
-            if (reader.GetPrompt())
-                ::fprintf (out_fh, "%s", reader.GetPrompt());
-            ::fflush (out_fh);
-        }
+        out_file.Printf ("%s\n", g_reader_instructions);
+        if (reader.GetPrompt())
+            out_file.Printf ("%s", reader.GetPrompt());
+        out_file.Flush();
         break;
 
     case eInputReaderDeactivate:
         break;
 
     case eInputReaderReactivate:
-        if (out_fh && reader.GetPrompt())
+        if (reader.GetPrompt())
         {
-            ::fprintf (out_fh, "%s", reader.GetPrompt());
-            ::fflush (out_fh);
+            out_file.Printf ("%s", reader.GetPrompt());
+            out_file.Flush();
         }
         break;
 
@@ -454,10 +451,10 @@
                     ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); 
             }
         }
-        if (out_fh && !reader.IsDone() && reader.GetPrompt())
+        if (!reader.IsDone() && reader.GetPrompt())
         {
-            ::fprintf (out_fh, "%s", reader.GetPrompt());
-            ::fflush (out_fh);
+            out_file.Printf ("%s", reader.GetPrompt());
+            out_file.Flush();
         }
         break;
         
@@ -475,8 +472,8 @@
                     ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->script_source.Clear();
                 }
             }
-            ::fprintf (out_fh, "Warning: No command attached to breakpoint.\n");
-            ::fflush (out_fh);
+            out_file.Printf ("Warning: No command attached to breakpoint.\n");
+            out_file.Flush();
         }
         break;
         
@@ -774,8 +771,8 @@
             Debugger &debugger = context->exe_ctx.target->GetDebugger();
             CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
         
-            FILE *out_fh = debugger.GetOutputFileHandle();
-            FILE *err_fh = debugger.GetErrorFileHandle();
+            File &out_file = debugger.GetOutputFile();
+            File &err_file = debugger.GetErrorFile();
                 
             uint32_t i;
             for (i = 0; i < num_commands; ++i)
@@ -797,30 +794,24 @@
                 {
                     if (i < num_commands - 1)
                     {
-                        if (out_fh)
-                            ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s."
-                                               " last command: \"%s\"\n", StateAsCString(internal_state),
-                                               commands.GetStringAtIndex(i));
+                        out_file.Printf ("Short-circuiting command execution because target state changed to %s."
+                                         " last command: \"%s\"\n", StateAsCString(internal_state),
+                                         commands.GetStringAtIndex(i));
                     }
                     break;
                 }
                 
-                if (out_fh)
-                    ::fprintf (out_fh, "%s", result.GetErrorStream().GetData());
-                if (err_fh)
-                    ::fprintf (err_fh, "%s", result.GetOutputStream().GetData());
+                out_file.Printf ("%s", result.GetErrorStream().GetData());
+                err_file.Printf ("%s", result.GetOutputStream().GetData());
                 result.Clear();
                 result.SetStatus (eReturnStatusSuccessFinishNoResult);
             }
 
-            if (err_fh && !result.Succeeded() && i < num_commands)
-                ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i));
+            if (!result.Succeeded() && i < num_commands)
+                err_file.Printf ("Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i));
 
-            if (out_fh)
-                ::fprintf (out_fh, "%s", result.GetErrorStream().GetData());
-
-            if (err_fh)
-                ::fprintf (err_fh, "%s", result.GetOutputStream().GetData());        
+            out_file.Printf ("%s", result.GetErrorStream().GetData());
+            err_file.Printf ("%s", result.GetOutputStream().GetData());        
         }
     }
     return ret_value;
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index cf090af..b887f1c 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -113,19 +113,16 @@
             std::string channel(args.GetArgumentAtIndex(0));
             args.Shift ();  // Shift off the channel
             StreamSP log_stream_sp;
-            StreamFile *log_file_ptr = NULL;  // This will get put in the log_stream_sp, no need to free it.
             if (m_options.log_file.empty())
             {
-                log_file_ptr = new StreamFile(m_interpreter.GetDebugger().GetOutputFileHandle());
-                log_stream_sp.reset(log_file_ptr);
+                log_stream_sp.reset(new StreamFile(m_interpreter.GetDebugger().GetOutputFile().GetDescriptor(), false));
             }
             else
             {
                 LogStreamMap::iterator pos = m_log_streams.find(m_options.log_file);
                 if (pos == m_log_streams.end())
                 {
-                    log_file_ptr = new StreamFile (m_options.log_file.c_str(), "w");
-                    log_stream_sp.reset (log_file_ptr);
+                    log_stream_sp.reset (new StreamFile (m_options.log_file.c_str()));
                     m_log_streams[m_options.log_file] = log_stream_sp;
                 }
                 else
@@ -133,10 +130,6 @@
             }
             assert (log_stream_sp.get());
             
-            // If we ended up making a StreamFile for log output, line buffer it.
-            if (log_file_ptr != NULL)
-                log_file_ptr->SetLineBuffered();
-                
             uint32_t log_options = m_options.log_options;
             if (log_options == 0)
                 log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE;
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index 3020c01..949cadc 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -347,7 +347,7 @@
             if (m_options.m_append_to_outfile)
                 mode[0] = 'a';
                 
-            if (outfile_stream.Open (path, mode))
+            if (outfile_stream.GetFile ().Open (path, File::eOpenOptionWrite | File::eOpenOptionCanCreate).Success())
             {
                 if (m_options.m_output_as_binary)
                 {