Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/ISO' into XEX
Browse files Browse the repository at this point in the history
  • Loading branch information
Gualdimar committed Oct 28, 2016
2 parents 02dba8a + aadc61f commit ec41f77
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
16 changes: 13 additions & 3 deletions Velocity/isodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void ISODialog::LoadDirectory(QObject *parent, std::vector<GdfxFileEntry> direct
}

item->setData(IsoTreeWidgetItemDataMagic, Qt::UserRole, (quint32)curEntry.magic);
item->setData(IsoTreeWidgetItemIsDirectory, Qt::UserRole, (bool)(curEntry.attributes & GdfxDirectory));
}
}

Expand Down Expand Up @@ -102,8 +103,13 @@ void ISODialog::showContextMenu(QPoint point)
QPoint globalPos = ui->treeWidget->mapToGlobal(point);
QMenu contextMenu;

if (ui->treeWidget->selectedItems().size() != 0)
contextMenu.addAction(QPixmap(":/Images/extract.png"), "Extract");
if (ui->treeWidget->selectedItems().size() == 1)
{
QTreeWidgetItem *selectedTreeWidgetItem = ui->treeWidget->selectedItems().at(0);
bool isDirectory = selectedTreeWidgetItem->data(IsoTreeWidgetItemIsDirectory, Qt::UserRole).toBool();
if (!isDirectory)
contextMenu.addAction(QPixmap(":/Images/extract.png"), "Extract");
}

QAction *selectedItem = contextMenu.exec(globalPos);
if (selectedItem == NULL)
Expand All @@ -115,7 +121,11 @@ void ISODialog::showContextMenu(QPoint point)
QString pathInISO = selectedItem->data(IsoTreeWidgetItemDataPathInISO, Qt::UserRole).toString();

QString outDirectory = QFileDialog::getExistingDirectory(this, "Choose a place to extract the file to", QtHelpers::DesktopLocation());
iso->ExtractFile(outDirectory.toStdString(), pathInISO.toStdString());

SingleProgressDialog *progressDialog = new SingleProgressDialog(FileSystemISO, iso, OpExtract, pathInISO, outDirectory, NULL, this);
progressDialog->setModal(true);
progressDialog->show();
progressDialog->start();

statusBar->showMessage("File extracted successfully", 5000);
}
Expand Down
3 changes: 2 additions & 1 deletion Velocity/isodialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class ISODialog;
enum IsoTreeWidgetItemData
{
IsoTreeWidgetItemDataPathInISO = 0,
IsoTreeWidgetItemDataMagic = 1
IsoTreeWidgetItemDataMagic = 1,
IsoTreeWidgetItemIsDirectory = 2
};

class ISODialog : public QDialog
Expand Down
12 changes: 11 additions & 1 deletion Velocity/singleprogressdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ SingleProgressDialog::SingleProgressDialog(FileSystem system, void *device, Oper
setWindowTitle("Extracting All Files");
ui->lblIcon->setPixmap(QPixmap(":/Images/extract.png"));
break;
case OpExtract:
setWindowTitle("Extracting File");
ui->lblIcon->setPixmap(QPixmap(":/Images/extract.png"));
break;
}
}

Expand Down Expand Up @@ -106,12 +110,18 @@ void SingleProgressDialog::start()
break;
}
case FileSystemISO:
{
ISO *iso = reinterpret_cast<ISO*>(device);
if (op == OpExtractAll)
{
ISO *iso = reinterpret_cast<ISO*>(device);
iso->ExtractAll(externalPath.toStdString(), UpdateProgress, this);
}
else if (op == OpExtract)
{
iso->ExtractFile(externalPath.toStdString(), internalPath.toStdString(), UpdateProgress, this);
}
break;
}
}
}
catch (string error)
Expand Down
7 changes: 6 additions & 1 deletion XboxInternals/Disc/ISO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ void ISO::ReadFileListing(vector<GdfxFileEntry> *entryList, DWORD sector, int si
io->SetPosition(entryAddress);

GdfxFileEntry current;
while (true)
DWORD bytesLeft = size;

while (bytesLeft != 0)
{
current.address = io->GetPosition();
current.fileIndex = 0;
Expand Down Expand Up @@ -265,6 +267,9 @@ void ISO::ReadFileListing(vector<GdfxFileEntry> *entryList, DWORD sector, int si
}
}

// calculate the amount of bytes left in the file listing table to process
bytesLeft -= entryAddress - current.address;

// back up to the entry
io->SetPosition(entryAddress);

Expand Down

0 comments on commit ec41f77

Please sign in to comment.