bool ChangeInfo::findNextRecordBounds(lChar8 * buf, int start, int end, int & recordStart, int & recordEnd) { int startTagPos = findBytes(buf, start, end, START_TAG_BYTES); if (startTagPos < 0) return false; int endTagPos = findBytes(buf, startTagPos, end, END_TAG_BYTES); if (endTagPos < 0) return false; recordStart = startTagPos; recordEnd = endTagPos + lStr_len(END_TAG_BYTES); return true; }
bool Connector::copyFile(QString fileName, QIODevice *target, uint &size, QDateTime &lastModified, bool infoOnly){ QByteArray content; QStringList infos; QRegExp findBytes("([0-9]+)B"); QRegExp findDate("([0-9]+)"); this->_socket->write("exportfile\n"); this->_socket->waitForReadyRead(); this->_socket->readAll(); this->_socket->write(fileName.toUtf8() + "\n"); this->_socket->waitForReadyRead(); //Metadaten einlesen infos = QString::fromUtf8(this->_socket->readAll()).split("\n"); if(infos.last().contains("@")){ return false; } findBytes.indexIn(infos.at(0)); findDate.indexIn(infos.at(1)); lastModified.setTime_t(QVariant(findDate.capturedTexts().at(1)).toUInt()); size = QVariant(findBytes.capturedTexts().at(1)).toUInt(); //Nur Metadaten? if(infoOnly){ this->_socket->write("n\n"); this->_socket->waitForReadyRead(); return true; } //Kopieren this->_socket->write("y\n"); content = this->_socket->readAll(); uint done = 0; while(!content.contains("\n")){ done += content.length(); emit copyFileProgress(fileName,done,size); if(content.length()%2 == 0){ target->write(QByteArray::fromHex(content)); content = QByteArray(); }else{ target->write(QByteArray::fromHex(content.left(content.length()-1))); content = content.right(1); } this->_socket->waitForReadyRead(100); qApp->processEvents(QEventLoop::AllEvents,100); content += this->_socket->readAll(); } content = content.replace("\nEND\n","\n"); target->write(QByteArray::fromHex(content.left(content.indexOf("\n")))); emit copyFileProgress(fileName,size,size); return true; }