added flags parameter to wxExecute(wxArrayString *) overloads

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2004-12-20 00:03:35 +00:00
parent f38f689990
commit 4d17215498
3 changed files with 19 additions and 14 deletions

View File

@ -521,14 +521,14 @@ processes.
\perlnote{In wxPerl this function is called \texttt{Wx::ExecuteArgs}} \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 \perlnote{In wxPerl this function is called \texttt{Wx::ExecuteStdout} and it
only takes the {\tt command} argument, only takes the {\tt command} argument,
and returns a 2-element list {\tt ( status, output )}, where {\tt output} is and returns a 2-element list {\tt ( status, output )}, where {\tt output} is
an array reference.} 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} \perlnote{In wxPerl this function is called \texttt{Wx::ExecuteStdoutStderr}
and it only takes the {\tt command} argument, 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). started their own session).
Finally, you may use the third overloaded version of this function to execute Finally, you may use the third overloaded version of this function to execute
a process (always synchronously) and capture its output in the array a process (always synchronously, the contents of \arg{flags} is or'd with
{\it output}. The fourth version adds the possibility to additionally capture \textt{wxEXEC\_SYNC}) and capture its output in the array \arg{output}. The
the messages from standard error output in the {\it errors} array. 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 {\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 this function from another thread will result in an assert failure in debug

View File

@ -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 // execute the command capturing its output into an array line by line, this is
// always synchronous // always synchronous
WXDLLIMPEXP_BASE long wxExecute(const wxString& command, WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
wxArrayString& output); wxArrayString& output,
int flags = 0);
// also capture stderr (also synchronous) // also capture stderr (also synchronous)
WXDLLIMPEXP_BASE long wxExecute(const wxString& command, WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
wxArrayString& output, wxArrayString& output,
wxArrayString& error); wxArrayString& error,
int flags = 0);
enum wxSignal enum wxSignal
{ {

View File

@ -479,13 +479,14 @@ static bool ReadAll(wxInputStream *is, wxArrayString& output)
// public versions of wxExecute() below // public versions of wxExecute() below
static long wxDoExecuteWithCapture(const wxString& command, static long wxDoExecuteWithCapture(const wxString& command,
wxArrayString& output, wxArrayString& output,
wxArrayString* error) wxArrayString* error,
int flags)
{ {
// create a wxProcess which will capture the output // create a wxProcess which will capture the output
wxProcess *process = new wxProcess; wxProcess *process = new wxProcess;
process->Redirect(); process->Redirect();
long rc = wxExecute(command, wxEXEC_SYNC, process); long rc = wxExecute(command, wxEXEC_SYNC | flags, process);
#if wxUSE_STREAMS #if wxUSE_STREAMS
if ( rc != -1 ) if ( rc != -1 )
@ -510,16 +511,17 @@ static long wxDoExecuteWithCapture(const wxString& command,
return rc; 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, long wxExecute(const wxString& command,
wxArrayString& output, wxArrayString& output,
wxArrayString& error) wxArrayString& error,
int flags)
{ {
return wxDoExecuteWithCapture(command, output, &error); return wxDoExecuteWithCapture(command, output, &error, flags);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------