From 4d1721549883e92f824038c4ba1b3f5d84318bbd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 20 Dec 2004 00:03:35 +0000 Subject: [PATCH 1/1] added flags parameter to wxExecute(wxArrayString *) overloads git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/function.tex | 11 ++++++----- include/wx/utils.h | 8 +++++--- src/common/utilscmn.cpp | 14 ++++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index bc1030da8a..7b87b4fdac 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -521,14 +521,14 @@ processes. \perlnote{In wxPerl this function is called \texttt{Wx::ExecuteArgs}} -\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{wxArrayString\& }{output}} +\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{wxArrayString\& }{output}, \param{int }{flags = 0}} \perlnote{In wxPerl this function is called \texttt{Wx::ExecuteStdout} and it only takes the {\tt command} argument, and returns a 2-element list {\tt ( status, output )}, where {\tt output} is an array reference.} -\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{wxArrayString\& }{output}, \param{wxArrayString\& }{errors}} +\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{wxArrayString\& }{output}, \param{wxArrayString\& }{errors}, \param{int }{flags = 0}} \perlnote{In wxPerl this function is called \texttt{Wx::ExecuteStdoutStderr} and it only takes the {\tt command} argument, @@ -585,9 +585,10 @@ will kill this process as well as all of its children (except those which have started their own session). Finally, you may use the third overloaded version of this function to execute -a process (always synchronously) and capture its output in the array -{\it output}. The fourth version adds the possibility to additionally capture -the messages from standard error output in the {\it errors} array. +a process (always synchronously, the contents of \arg{flags} is or'd with +\textt{wxEXEC\_SYNC}) and capture its output in the array \arg{output}. The +fourth version adds the possibility to additionally capture the messages from +standard error output in the \arg{errors} array. {\bf NB:} Currently wxExecute() can only be used from the main thread, calling this function from another thread will result in an assert failure in debug diff --git a/include/wx/utils.h b/include/wx/utils.h index 2450c08a9b..bca3d0be0a 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -194,12 +194,14 @@ WXDLLIMPEXP_BASE long wxExecute(const wxString& command, int flags = wxEXEC_ASYN // execute the command capturing its output into an array line by line, this is // always synchronous WXDLLIMPEXP_BASE long wxExecute(const wxString& command, - wxArrayString& output); + wxArrayString& output, + int flags = 0); // also capture stderr (also synchronous) WXDLLIMPEXP_BASE long wxExecute(const wxString& command, - wxArrayString& output, - wxArrayString& error); + wxArrayString& output, + wxArrayString& error, + int flags = 0); enum wxSignal { diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 9f14c1b3cb..02c4774c93 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -479,13 +479,14 @@ static bool ReadAll(wxInputStream *is, wxArrayString& output) // public versions of wxExecute() below static long wxDoExecuteWithCapture(const wxString& command, wxArrayString& output, - wxArrayString* error) + wxArrayString* error, + int flags) { // create a wxProcess which will capture the output wxProcess *process = new wxProcess; process->Redirect(); - long rc = wxExecute(command, wxEXEC_SYNC, process); + long rc = wxExecute(command, wxEXEC_SYNC | flags, process); #if wxUSE_STREAMS if ( rc != -1 ) @@ -510,16 +511,17 @@ static long wxDoExecuteWithCapture(const wxString& command, return rc; } -long wxExecute(const wxString& command, wxArrayString& output) +long wxExecute(const wxString& command, wxArrayString& output, int flags) { - return wxDoExecuteWithCapture(command, output, NULL); + return wxDoExecuteWithCapture(command, output, NULL, flags); } long wxExecute(const wxString& command, wxArrayString& output, - wxArrayString& error) + wxArrayString& error, + int flags) { - return wxDoExecuteWithCapture(command, output, &error); + return wxDoExecuteWithCapture(command, output, &error, flags); } // ---------------------------------------------------------------------------- -- 2.45.2