Changeset 22529
- Timestamp:
- 2010-07-30T15:35:04+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/search4j/libsearch4j.cpp
r20709 r22529 70 70 int process_and_catch_output( string command, string &output ) { 71 71 72 #ifdef WINDOWS73 74 char cmd[1024] = "cmd.exe /c ";75 strcat(cmd, command.c_str());76 strcat(cmd, " > cmd_output.txt 2>&1");77 //cerr << "command: " << cmd << endl;78 int code = process( cmd, false );79 if ( code!= 0 )80 return code;81 82 string line;83 ifstream myfile("cmd_output.txt");84 if ( !myfile.is_open() ) {85 return -1;86 }87 88 while ( !myfile.eof() ) {89 getline(myfile,line);90 output.append( line );91 }92 93 myfile.close();94 95 _unlink( "cmd_output.txt" );96 97 return code;98 99 #else100 101 72 FILE *pPipe; 102 73 … … 106 77 107 78 //if ( verbose ) cout << "process(): running '" << command << "'" << endl; 79 #ifdef WINDOWS 80 if( (pPipe = _popen( cmd, "rt" )) == NULL ) { 81 _pclose( pPipe ); 82 #else 108 83 if( (pPipe = popen( cmd, "r" )) == NULL ) { 109 //if ( verbose ) cout << "could not start process" << endl;110 84 pclose( pPipe ); 85 #endif 111 86 return -1; 112 87 } 113 114 88 //if ( verbose ) cout << "started process" << endl; 115 89 … … 130 104 131 105 /* Close pipe and return return value of pPipe. */ 106 #ifdef WINDOWS 107 int code = _pclose( pPipe ); 108 #else 132 109 int code = pclose( pPipe ); 110 #endif 111 133 112 return code; 134 135 #endif136 113 137 114 }
Note:
See TracChangeset
for help on using the changeset viewer.