size_t RubyIOStore::TransferTo2(BufferedTransformation& target, CryptoPP::lword& transferBytes, const std::string& channel, bool blocking) { if (!m_stream) { transferBytes = 0; return 0; } lword size = transferBytes; transferBytes = 0; if (m_waiting) { goto output; } while (size && !RTEST(rb_funcall(*m_stream, rb_intern("eof?"), 0))) { { VALUE buffer; size_t spaceSize = 1024; m_space = HelpCreatePutSpace(target, channel, 1, UnsignedMin(size_t(0) - 1, size), spaceSize); buffer = rb_funcall(*m_stream, rb_intern("read"), 1, UINT2NUM(STDMIN(size, (lword) spaceSize))); if (TYPE(buffer) != T_STRING) { throw ReadErr(); } memcpy(m_space, StringValuePtr(buffer), RSTRING_LEN(buffer)); m_len = RSTRING_LEN(buffer); } size_t blockedBytes; output: blockedBytes = target.ChannelPutModifiable2(channel, m_space, m_len, 0, blocking); m_waiting = blockedBytes > 0; if (m_waiting) { return blockedBytes; } size -= m_len; transferBytes += m_len; } if (!RTEST(rb_funcall(*m_stream, rb_intern("eof?"), 0))) { throw ReadErr(); } return 0; }
void MainWindow::bash(QString command) { QProcess *p = new QProcess( this ); if (p) { p->setEnvironment( QProcess::systemEnvironment() ); p->setProcessChannelMode( QProcess::MergedChannels ); p->start( command ); p->waitForStarted(); connect( p, SIGNAL(readyReadStandardOutput()), this, SLOT(ReadOut()) ); connect( p, SIGNAL(readyReadStandardError()), this, SLOT(ReadErr()) ); } }
void MainWindow::on_downloadbutton_clicked() { QProcess *download = new QProcess(); if (download) { QString url; url = ui->urlbox->text(); // qDebug()<<home; qDebug()<<url; download->start("wget", QStringList() << url << "-P" << "/home/arun/Downloads/arun"); qDebug()<<download; download->waitForStarted(); connect( download, SIGNAL(readyReadStandardOutput()), this, SLOT(on_textBrowser_sourceChanged()) ); connect( download, SIGNAL(readyReadStandardError()), this, SLOT(ReadErr()) ); } }
unsigned int FileSource::Pump(unsigned int size) { unsigned int total=0; SecByteBlock buffer(STDMIN(size, BUFFER_SIZE)); while (size && in.good()) { in.read((char *)buffer.ptr, STDMIN(size, BUFFER_SIZE)); unsigned l = in.gcount(); outQueue->Put(buffer, l); size -= l; total += l; } if (!in.good() && !in.eof()) throw ReadErr(); return total; }
size_t FileStore::TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel, bool blocking) { if (!m_stream) { transferBytes = 0; return 0; } lword size=transferBytes; transferBytes = 0; if (m_waiting) goto output; while (size && m_stream->good()) { { size_t spaceSize = 1024; m_space = HelpCreatePutSpace(target, channel, 1, UnsignedMin(size_t(SIZE_MAX), size), spaceSize); m_stream->read((char *)m_space, (unsigned int)STDMIN(size, (lword)spaceSize)); } m_len = (size_t)m_stream->gcount(); size_t blockedBytes; output: blockedBytes = target.ChannelPutModifiable2(channel, m_space, m_len, 0, blocking); m_waiting = blockedBytes > 0; if (m_waiting) return blockedBytes; size -= m_len; transferBytes += m_len; } if (!m_stream->good() && !m_stream->eof()) throw ReadErr(); return 0; }
unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking) { if( !m_file.IsGood() ) { transferBytes = 0; return 0; } unsigned long size=transferBytes; transferBytes = 0; if (m_waiting) goto output; while( size && !m_file.AtEOF() ) { { unsigned int spaceSize = 1024; m_space = HelpCreatePutSpace(target, channel, 1, (unsigned int)STDMIN(size, (unsigned long)UINT_MAX), spaceSize); m_len = m_file.Read( (char *)m_space, STDMIN(size, (unsigned long)spaceSize)); if( m_len == -1 ) throw ReadErr( m_file ); } unsigned int blockedBytes; output: blockedBytes = target.ChannelPutModifiable2(channel, m_space, m_len, 0, blocking); m_waiting = blockedBytes > 0; if (m_waiting) return blockedBytes; size -= m_len; transferBytes += m_len; } return 0; }