MCPcopy Create free account
hub / github.com/collin80/SavvyCAN / isNativeCSVFile

Method isNativeCSVFile

framefileio.cpp:1400–1450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1398}
1399
1400bool FrameFileIO::isNativeCSVFile(QString filename)
1401{
1402 QFile *inFile = new QFile(filename);
1403 QByteArray line;
1404 int fileVersion = 1;
1405 bool isMatch = true;
1406
1407 if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
1408 {
1409 delete inFile;
1410 return false;
1411 }
1412 try
1413 {
1414 line = inFile->readLine().toUpper(); //read out the header first and discard it.
1415 if (line.length() < 23) isMatch = false;
1416 else if (line.at(23) == 'D') fileVersion = 2; //Dir is found starting at position 23 if this is a V2 file
1417
1418 if (!line.contains("TIME STAMP")) isMatch = false;
1419 if (!line.contains("EXTENDED")) isMatch = false;
1420 if (!line.contains("D1")) isMatch = false;
1421
1422 if (!inFile->atEnd()) {
1423 line = inFile->readLine().simplified();
1424 if (line.length() > 2)
1425 {
1426 QList<QByteArray> tokens = line.split(',');
1427 if (tokens.length() >= 5)
1428 {
1429 if (fileVersion == 1)
1430 {
1431 if (tokens[4].toUInt() > 8) isMatch = false;
1432 }
1433 else if (fileVersion == 2)
1434 {
1435 if ( tokens[5].toUInt() > 8) isMatch = false;
1436 }
1437 }
1438 else isMatch = false;
1439 }
1440 }
1441 }
1442 catch (...)
1443 {
1444 isMatch = false;
1445 }
1446 inFile->close();
1447 delete inFile;
1448
1449 return isMatch;
1450}
1451
1452//The "native" file format for this program
1453//Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8

Callers

nothing calls this directly

Calls 2

atMethod · 0.80
containsMethod · 0.80

Tested by

no test coverage detected