QT second file not being added to ByteArray

46 Views Asked by At

I am trying to merge 2 files,they contain hex data presented like this:

:10000000000404000000000028160000281600006C
:1000100028160000281600002816000028160000E8
:1000200028160000281600002816000028160000D8
:1000300028160000281600002816000028160000C8
:100040002816000028160000087802002816000074

For some reason only the first file is ending up in the output, here is my relevant source:

QFile filea(file1);
QFile fileb(file2);
QFile result("C:/Users/Aaron/Desktop/mergedfile.rfu");

if(filea.open(QIODevice::ReadOnly) && fileb.open(QIODevice::ReadOnly) && result.open(QIODevice::WriteOnly)){
    QByteArray ba;
    QTextStream ts(&ba, QIODevice::ReadWrite);


    ts << filea.readAll();
    qDebug() << "check ts at 0" << ts.seek(0) <<"ts at 1" << ts.seek(1);
    ts << fileb.readAll();
    result.write(ba);
    result.flush();

I was using QTextStream instead of QDataStream because DataStream was placing junk at the beginning of the output file.

0

There are 0 best solutions below