aboutsummaryrefslogtreecommitdiff
path: root/src/builder.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/builder.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/builder.cpp b/src/builder.cpp
index 8fd72bb..8c3bbbb 100644
--- a/src/builder.cpp
+++ b/src/builder.cpp
@@ -799,3 +799,27 @@ std::list<std::string> Builder::findTargets( const char *sRegex )
799 return lTmp; 799 return lTmp;
800} 800}
801 801
802std::string Builder::cmdToString( const char *sCmd )
803{
804 std::string buf;
805 FILE *pr = popen( sCmd, "r" );
806 if( pr == NULL )
807 throw BuildException("Couldn't execute program \"%s\"", sCmd );
808
809 char cbuf[2048];
810
811 for(;;)
812 {
813 int nRead = fread( cbuf, 1, 2048, pr );
814 for( int j = 0; j < nRead; j++ )
815 if( cbuf[j] != '\n' && cbuf[j] != '\r' )
816 buf.append( cbuf+j, 1 );
817 if( feof( pr ) )
818 break;
819 }
820
821 pclose( pr );
822
823 return buf;
824}
825