Ejemplo n.º 1
0
// the KProcess passes the arguments to tar, and tar's output is piped here.
// The output is shown to _tarParser->slotData(), which figures out which files
// are going to tape and their file parameters, and saves these data into
// kdat's archive.  The raw data are then written to tape with write().
// 2002-01-27 LEW
void BackupDlg::slotStdout( KProcess*, char* buf, int len )
{
    // Don't start throughput timer until the first block of data is written.
    if ( _startTime == 0 ) {
        _startTime = time( NULL );
    }

    /* 2002-01-26 LEW */
    // printf("got a line from tar, length %d bytes...\n", len);
    /* 2002-01-26 LEW */

    // Pass the data through the tar parser to extract the file info.
    _tarParser->slotData( buf, len );

    _totalKBytes += (float)len / 1024.0;
    assert( len % 512 == 0 );
    _totalRecords += len / 512;
    if ( TapeDrive::instance()->write( buf, len ) < len ) {
        _log->append( i18n( "*** Write failed, giving up." ) );

        if ( _proc ) {
            _proc->kill();
        }

        slotProcessExited( 0 );
    }
}
QString KSimpleProcess::execInternal( const QString &args, bool addStdError)
{
	m_proc->setArguments( splitArgList( args ));
	connect(m_proc, SIGNAL(processExited()), this, SLOT(slotProcessExited()));
	connect(m_proc, SIGNAL(readyReadStdout()), this, SLOT(slotReceivedStdout()));
	if( addStdError )
		connect(m_proc, SIGNAL(readyReadStderr()), this, SLOT(slotReceivedStderr()));

	if ( !m_proc->start()  )
		return i18n("Could not run command '%1'.").arg( args.latin1() );
	enter_loop();
	return m_currBuffer;
}