~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to CodeLite/procutils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-02-10 02:27:55 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20090210022755-mxlvij3ndab1n5ty
Tags: upstream-1.0.2759+dfsg
ImportĀ upstreamĀ versionĀ 1.0.2759+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//////////////////////////////////////////////////////////////////////////////
2
2
//////////////////////////////////////////////////////////////////////////////
3
3
//
4
 
// copyright            : (C) 2008 by Eran Ifrah                            
5
 
// file name            : procutils.cpp              
6
 
//                                                                          
 
4
// copyright            : (C) 2008 by Eran Ifrah
 
5
// file name            : procutils.cpp
 
6
//
7
7
// -------------------------------------------------------------------------
8
 
// A                                                                        
9
 
//              _____           _      _     _ _                            
10
 
//             /  __ \         | |    | |   (_) |                           
11
 
//             | /  \/ ___   __| | ___| |    _| |_ ___                      
12
 
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )                     
13
 
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/                     
14
 
//              \____/\___/ \__,_|\___\_____/_|\__\___|                     
15
 
//                                                                          
16
 
//                                                  F i l e                 
17
 
//                                                                          
18
 
//    This program is free software; you can redistribute it and/or modify  
19
 
//    it under the terms of the GNU General Public License as published by  
20
 
//    the Free Software Foundation; either version 2 of the License, or     
21
 
//    (at your option) any later version.                                   
22
 
//                                                                          
 
8
// A
 
9
//              _____           _      _     _ _
 
10
//             /  __ \         | |    | |   (_) |
 
11
//             | /  \/ ___   __| | ___| |    _| |_ ___
 
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
 
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
 
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|
 
15
//
 
16
//                                                  F i l e
 
17
//
 
18
//    This program is free software; you can redistribute it and/or modify
 
19
//    it under the terms of the GNU General Public License as published by
 
20
//    the Free Software Foundation; either version 2 of the License, or
 
21
//    (at your option) any later version.
 
22
//
23
23
//////////////////////////////////////////////////////////////////////////////
24
24
//////////////////////////////////////////////////////////////////////////////
25
25
 #include "wx/tokenzr.h"
391
391
        if (!proc) {
392
392
                return;
393
393
        }
394
 
        
 
394
 
395
395
        // wait for the process to terminate
396
396
        wxString tmpbuf;
397
397
        wxString buff;
398
398
        static int maxRetries (1000);
399
 
        
 
399
 
400
400
        int retries(0);
401
401
        while (proc->IsAlive() && retries < maxRetries) {
402
402
                proc->Read(tmpbuf);
404
404
                wxThread::Sleep(100);
405
405
                retries++;
406
406
        }
407
 
        
 
407
 
408
408
        tmpbuf.Empty();
409
409
        proc->Read(tmpbuf);
410
410
        while( tmpbuf.IsEmpty() == false && retries < maxRetries) {
413
413
                proc->Read(tmpbuf);
414
414
                retries++;
415
415
        }
416
 
        
417
 
        //convert buff into wxArrayString
418
 
        output = wxStringTokenize(buff, wxT("\n"));
 
416
 
 
417
        // Convert buff into wxArrayString
 
418
        buff.Trim().Trim(false);
 
419
        wxString s;
 
420
        int where = buff.Find(wxT("\n"));
 
421
        while( where != wxNOT_FOUND ) {
 
422
                // use c_str() to make sure we create a unique copy
 
423
                s = buff.Mid(0, where).c_str();
 
424
                s.Trim().Trim(false);
 
425
                output.Add(s.c_str());
 
426
                buff.Remove(0, where+1);
 
427
 
 
428
                where = buff.Find(wxT("\n"));
 
429
        }
 
430
 
 
431
        if(buff.empty() == false){
 
432
                s = buff.Trim().Trim(false);
 
433
                output.Add(s.c_str());
 
434
        }
 
435
 
419
436
        proc->Cleanup();
420
437
        delete proc;
421
438