as_dataop.cpp

changeset 10
579d467531cc
parent 3
c1941114ca88
child 11
d926203bd2a8
equal deleted inserted replaced
1:5afd37b95614 2:1b7dfbc1a15c
453 // Convenience method to validate AS data in a file 453 // Convenience method to validate AS data in a file
454 // 454 //
455 const bool Titraqform::validateData(QFile &Filin) const 455 const bool Titraqform::validateData(QFile &Filin) const
456 { 456 {
457 QString Firstline; // Will contain the first line of text 457 QString Firstline; // Will contain the first line of text
458 char *pReadline; // Contains the read line of text file 458 char szReadline[QString(TITRAQ_DATAPATTERN).length() + 4L]; // File line
459 bool bRet = false; // Set the initial return value 459 bool bRet = false; // Set the initial return value
460 460
461 if (Filin.isOpen()) { // Check open state of file 461 if (Filin.isOpen()) { // Check open state of file
462 Filin.flush(); // Not sure if this is needed 462 Filin.flush(); // Not sure if this is needed
463 Filin.reset(); // Set the file index position to 0 463 Filin.reset(); // Set the file index position to 0
464 Filin.readLine(pReadline, QString(TITRAQ_DATAPATTERN).length() + 2L); 464 Filin.readLine(szReadline, QString(TITRAQ_DATAPATTERN).length() + 2L);
465 } 465 }
466 else { 466 else {
467 if (!Filin.open(QIODevice::ReadOnly)) // Try to open file 467 if (!Filin.open(QIODevice::ReadOnly)) // Try to open file
468 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL)); 468 throw Genexcept(trUtf8(TITRAQ_READPFILFAIL));
469 else { // File is now open 469 else { // File is now open
470 Filin.readLine(pReadline, QString(TITRAQ_DATAPATTERN).length() + 2L); 470 Filin.readLine(szReadline, QString(TITRAQ_DATAPATTERN).length() + 2L);
471 Filin.close(); // Remember to close 471 Filin.close(); // Remember to close
472 } 472 }
473 } 473 }
474 474
475 try { // Pass off to worker method 475 try { // Pass off to worker method
476 Firstline = QString::fromAscii(pReadline); 476 Firstline = QString::fromAscii(szReadline);
477 bRet = this->validateData(Firstline); 477 bRet = this->validateData(Firstline);
478 } 478 }
479 catch (Genexcept &) { 479 catch (Genexcept &) {
480 throw; // Rethrow onwards 480 throw; // Rethrow onwards
481 } 481 }

mercurial