Skip to content

Commit

Permalink
ignore files that are read incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
Renari committed Jun 8, 2016
1 parent 84f30fc commit b3c1a3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 6 additions & 2 deletions SKFM/catfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ CatFile::ExtraData::ExtraData(int offset, int *fileCount, QByteArray *fileData)
QBuffer buffer(fileData);
buffer.open(QBuffer::ReadOnly);
buffer.seek(offset);
if (buffer.peek(3).toStdString() == "GXT")
QByteArray gxt = buffer.peek(3);
if (QString(gxt.data()) == "GXT")
{
throw;
extraHeader = 0;
extraCount = 0;
extraSize = 0;
return;
}
buffer.read((char*)&extraHeader, sizeof(extraHeader));
buffer.read((char*)&extraCount, sizeof(extraCount));
Expand Down
15 changes: 5 additions & 10 deletions SKFM/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ void MainWindow::on_actionOpen_triggered()
ui->treeWidget->clear();
item->setText(0, QFileInfo(filePath).baseName());

try
{
if (!file.suffix().compare("gxt", Qt::CaseInsensitive))
{
openedResource = new GxtFile(filePath);
Expand All @@ -59,19 +57,16 @@ void MainWindow::on_actionOpen_triggered()
{
openedResource = new CatFile(filePath);
}
}
catch(int e)

int fileCount = openedResource->getFileCount();

if(fileCount == 0)
{
ui->actionSave->setEnabled(false);
ui->treeWidget->clear();
QMessageBox msgBox;
msgBox.setText("This file isn't currently supported." + e);
msgBox.exec();
ui->actionSave->setEnabled(false);
return;
}

int fileCount = openedResource->getFileCount();

for (int i = 1; i <= fileCount; i++)
{
QTreeWidgetItem *childItem = new QTreeWidgetItem();
Expand Down

0 comments on commit b3c1a3e

Please sign in to comment.