From aa1bbe3277842a9a6e7db5227b35f1fbea50b7a6 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Sun, 22 Jan 2012 10:58:16 -0500
Subject: [PATCH] Make LLProcess::Params streamable; use that in
 LLExternalEditor.

---
 indra/llcommon/llprocess.cpp       | 15 +++++++++++++++
 indra/llcommon/llprocess.h         |  4 ++++
 indra/newview/llexternaleditor.cpp | 14 ++------------
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp
index d30d87411d1..9d6c19f1dd9 100644
--- a/indra/llcommon/llprocess.cpp
+++ b/indra/llcommon/llprocess.cpp
@@ -81,6 +81,21 @@ bool LLProcess::isRunning(void)
 	return (mProcessID != 0);
 }
 
+std::ostream& operator<<(std::ostream& out, const LLProcess::Params& params)
+{
+	std::string cwd(params.cwd);
+	if (! cwd.empty())
+	{
+		out << "cd '" << cwd << "': ";
+	}
+	out << '"' << std::string(params.executable) << '"';
+	BOOST_FOREACH(const std::string& arg, params.args)
+	{
+		out << " \"" << arg << '"';
+	}
+	return out;
+}
+
 /*****************************************************************************
 *   Windows specific
 *****************************************************************************/
diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h
index 9ea129baf28..7dbdf23679e 100644
--- a/indra/llcommon/llprocess.h
+++ b/indra/llcommon/llprocess.h
@@ -31,6 +31,7 @@
 #include "llsdparam.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/noncopyable.hpp>
+#include <iosfwd>                   // std::ostream
 
 #if LL_WINDOWS
 #define WIN32_LEAN_AND_MEAN
@@ -124,4 +125,7 @@ class LL_COMMON_API LLProcess: public boost::noncopyable
 	bool mAutokill;
 };
 
+/// for logging
+LL_COMMON_API std::ostream& operator<<(std::ostream&, const LLProcess::Params&);
+
 #endif // LL_LLPROCESS_H
diff --git a/indra/newview/llexternaleditor.cpp b/indra/newview/llexternaleditor.cpp
index 3dfebad958a..0d3ed0ba355 100644
--- a/indra/newview/llexternaleditor.cpp
+++ b/indra/newview/llexternaleditor.cpp
@@ -74,12 +74,7 @@ LLExternalEditor::EErrorCode LLExternalEditor::setCommand(const std::string& env
 		llinfos << "Adding the filename marker (" << sFilenameMarker << ")" << llendl;
 	}
 
-	llinfos << "Setting command [" << bin_path;
-	BOOST_FOREACH(const std::string& arg, mProcessParams.args)
-	{
-		llcont << " \"" << arg << "\"";
-	}
-	llcont << "]" << llendl;
+	llinfos << "Setting command [" << mProcessParams << "]" << llendl;
 
 	return EC_SUCCESS;
 }
@@ -108,12 +103,7 @@ LLExternalEditor::EErrorCode LLExternalEditor::run(const std::string& file_path)
 	}
 
 	// Run the editor.
-	llinfos << "Running editor command [" << std::string(params.executable);
-	BOOST_FOREACH(const std::string& arg, params.args)
-	{
-		llcont << " \"" << arg << "\"";
-	}
-	llcont << "]" << llendl;
+	llinfos << "Running editor command [" << params << "]" << llendl;
 	// Prevent killing the process in destructor.
 	params.autokill = false;
 	return LLProcess::create(params) ? EC_SUCCESS : EC_FAILED_TO_RUN;
-- 
GitLab