2 /******************************************************************************
3 * MODULE : qt_system.cpp
4 * DESCRIPTION: external command launcher
5 * COPYRIGHT : (C) 2009 David MICHEL
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
12 #include "qt_sys_utils.hpp"
20 qt_system (string cmd
, string
& result
) {
23 proc
.setProcessChannelMode (QProcess::MergedChannels
);
24 char* _cmd
= as_charp (cmd
);
25 #if defined (__MINGW__) || defined (__MINGW32__)
26 QString qcmd
= "CMD /S /C ";
29 QString qcmd
= "sh -c \"";
33 tm_delete_array (_cmd
);
35 if (! proc
.waitForStarted ()) {
36 if (DEBUG_STD
) cerr
<< "TeXmacs] System: failed to launch command\n";
39 proc
.closeWriteChannel ();
40 if (! proc
.waitForFinished ()) {
41 if (DEBUG_STD
) cerr
<< "TeXmacs] System: waiting for too long\n";
44 result
= proc
.readAll ().constData ();
45 if (DEBUG_STD
) cerr
<< result
;
46 return proc
.exitCode ();