success!

finally got the iBike CSV file support added to Golden Cheetah. the issue revolved around line endings on the iBike file that a user supplied. the file had CR (old-style Macintosh) line endings, and QTextStream::readLine() doesn’t honor them…reading the entire file at once.

the solution was pretty simple: use readLine() THEN split(‘\r’) and loop through each piece. files with LF endings will be read in correctly, and the split will only result in one element. files with CR will be read incorrectly (as one big chunk) and then split into lines. the rest of the code is agnostic to the differences. snippet for reference:

        QString linesIn = is.readLine();
        QStringList lines = linesIn.split('\r');
        // workaround for empty lines
        if(lines.size() == 0) {
            lineno++;
            continue;
        }
        for (int li = 0; li < lines.size(); ++li) { 
            QString line = lines[li];

ok, back to packing for the move.


Posted

in

by

Comments

Leave a Reply