Example #1
0
void ZipArch::open()
{
    setHeaders();

    m_buffer = "";
    m_header_removed = false;
    m_finished = false;

    KProcess *kp = m_currentProcess = new KProcess;

    *kp << m_unarchiver_program << "-v" << m_filename;

    connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
             SLOT( slotReceivedTOC(KProcess*, char*, int) ) );
    connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
             SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
    connect( kp, SIGNAL( processExited(KProcess*) ),
             SLOT( slotOpenExited(KProcess*) ) );

    if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
    {
        KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
        emit sigOpen( this, false, QString::null, 0 );
    }
}
Example #2
0
void TarArch::createTmp()
{
    if ( compressed )
    {
        if ( !QFile::exists(tmpfile) )
        {
            QString strUncompressor = getUnCompressor();
            // at least lzop doesn't want to pipe zerosize/nonexistent files
            QFile originalFile( m_filename );
            if ( strUncompressor != "gunzip" && strUncompressor !="bunzip2" &&
                ( !originalFile.exists() || originalFile.size() == 0 ) )
            {
                QFile temp( tmpfile );
                temp.open( IO_ReadWrite );
                temp.close();
                emit createTempDone();
                return;
            }
            // the tmpfile does not yet exist, so we create it.
            createTmpInProgress = true;
            int f_desc = KDE_open(QFile::encodeName(tmpfile), O_CREAT | O_TRUNC | O_WRONLY, 0666);
            if (f_desc != -1)
                fd = fdopen( f_desc, "w" );
            else
                fd = NULL;

            KProcess *kp = m_currentProcess = new KProcess;
            kp->clearArguments();
            kdDebug(1601) << "Uncompressor is " << strUncompressor << endl;
            *kp << strUncompressor;
            KProcess::Communication flag = KProcess::AllOutput;
            if (strUncompressor == "lzop")
            {
                // setting up a pty for lzop, since it doesn't like stdin to
                // be /dev/null ( "no filename allowed when reading from stdin" )
                // - but it used to work without this ? ( Feb 13, 2003 )
                kp->setUsePty( KProcess::Stdin, false );
                flag = KProcess::Stdout;
                *kp << "-d";
            }
            *kp << "-c" << m_filename;

            connect(kp, SIGNAL(processExited(KProcess *)),
                    this, SLOT(createTmpFinished(KProcess *)));
            connect(kp, SIGNAL(receivedStdout(KProcess*, char*, int)),
                    this, SLOT(createTmpProgress( KProcess *, char *, int )));
            connect( kp, SIGNAL(receivedStderr(KProcess*, char*, int)),
                    this, SLOT(slotReceivedOutput(KProcess*, char*, int)));
            if (kp->start(KProcess::NotifyOnExit, flag ) == false)
            {
                KMessageBox::error(0, i18n("Unable to fork a decompressor"));
		emit sigOpen( this, false, QString::null, 0 );
            }
        }
        else
        {