summaryrefslogtreecommitdiff
path: root/tests/manual/trk/swapendian.cpp
blob: 4b6dd5cb1c7c30e52ca14c685e270a79010bfdf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


#include <QtCore>

int main(int argc, char *argv[])
{
    QFile file1(argv[1]);
    file1.open(QIODevice::ReadOnly);

    QByteArray ba = file1.readAll();
    file1.close();

    for (int i = 0; i < ba.size(); i += 4) {
        char c = ba[i]; ba[i] = ba[i + 3]; ba[i + 3] = c;
        c = ba[i + 1]; ba[i + 1] = ba[i + 2]; ba[i + 2] = c;
    }

    QFile file2(argv[2]);
    file2.open(QIODevice::WriteOnly);
    file2.write(ba);
    file2.close();
}