Fix discovery of sox binary

Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/k3b/issues/58
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
pull/60/head
Alexander Golubev 3 weeks ago
parent 8e4a3a799a
commit 3067884e74

@ -34,6 +34,7 @@
#include <tqcombobox.h> #include <tqcombobox.h>
#include <tqcheckbox.h> #include <tqcheckbox.h>
#include <tqlayout.h> #include <tqlayout.h>
#include <tqregexp.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
@ -65,47 +66,33 @@ class K3bSoxProgram : public K3bExternalProgram
if( !TQFile::exists( path ) ) if( !TQFile::exists( path ) )
return false; return false;
K3bExternalBin* bin = 0;
// probe version // probe version
TDEProcess vp; TDEProcess vp;
K3bProcessOutputCollector out( &vp ); K3bProcessOutputCollector out( &vp );
vp << path << "-h"; vp << path << "-h";
if( vp.start( TDEProcess::Block, TDEProcess::AllOutput ) ) { if( vp.start( TDEProcess::Block, TDEProcess::AllOutput ) ) {
int pos = out.output().find( "sox: SoX Version" ); TQRegExp versionRe ("sox: +(SoX )?(Version |v)([^\\n]+)");
if ( pos < 0 ) // Should match:
pos = out.output().find( "sox: SoX v" ); // newer sox versions // * sox: Version 12.2.3
int endPos = out.output().find( "\n", pos ); // * sox: SoX Version 12.18.1
if( pos > 0 && endPos > 0 ) { // * sox: SoX v14.0.0
pos += 17; // * sox: SoX v14.4.0
bin = new K3bExternalBin( this ); int pos = versionRe.search( out.output() );
if( pos > 0 ) {
TQString version = versionRe.cap(3);
K3bExternalBin* bin = new K3bExternalBin( this );
bin->path = path; bin->path = path;
bin->version = out.output().mid( pos, endPos-pos ); bin->version = version;
addBin( bin ); addBin( bin );
return true; return true;
} }
else {
pos = out.output().find( "sox: Version" );
endPos = out.output().find( "\n", pos );
if( pos > 0 && endPos > 0 ) {
pos += 13;
bin = new K3bExternalBin( this );
bin->path = path;
bin->version = out.output().mid( pos, endPos-pos );
addBin( bin );
return true;
}
else
return false;
}
} }
else return false;
return false;
} }
}; };

Loading…
Cancel
Save