Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Display error messages when failing to compress/decompress games.
Fixes issue 4681.
  • Loading branch information
jordan-woyak committed Jan 10, 2013
1 parent 32855a2 commit 6598462
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Source/Core/DiscIO/Src/CompressedBlob.cpp
Expand Up @@ -296,9 +296,13 @@ bool DecompressBlobToFile(const char* infile, const char* outfile, CompressCB ca
}

CompressedBlobReader* reader = CompressedBlobReader::Create(infile);
if (!reader) return false;
if (!reader)
return false;

File::IOFile f(outfile, "wb");
if (!f)
return false;

const CompressedBlobHeader &header = reader->GetHeader();
u8* buffer = new u8[header.block_size];
int progress_monitor = max<int>(1, header.num_blocks / 100);
Expand Down
24 changes: 20 additions & 4 deletions Source/Core/DolphinWX/Src/GameListCtrl.cpp
Expand Up @@ -1121,6 +1121,9 @@ void CGameListCtrl::CompressSelection(bool _compress)
if (browseDialog.ShowModal() != wxID_OK)
return;

bool all_good = true;

{
wxProgressDialog progressDialog(
_compress ? _("Compressing ISO") : _("Decompressing ISO"),
_("Working..."),
Expand Down Expand Up @@ -1157,7 +1160,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
wxYES_NO) == wxNO)
continue;

DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
all_good &= DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
OutputFileName.c_str(),
(iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0,
16384, &MultiCompressCB, &progressDialog);
Expand Down Expand Up @@ -1185,11 +1188,16 @@ void CGameListCtrl::CompressSelection(bool _compress)
wxYES_NO) == wxNO)
continue;

DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
all_good &= DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
OutputFileName.c_str(), &MultiCompressCB, &progressDialog);
}
m_currentItem++;
}
}

if (!all_good)
wxMessageBox(_("Dolphin was unable to complete the requested action."));

Update();
}

Expand Down Expand Up @@ -1249,6 +1257,9 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
_("Confirm File Overwrite"),
wxYES_NO) == wxNO);

bool all_good = false;

{
wxProgressDialog dialog(
iso->IsCompressed() ? _("Decompressing ISO") : _("Compressing ISO"),
_("Working..."),
Expand All @@ -1259,14 +1270,19 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
wxPD_SMOOTH
);


if (iso->IsCompressed())
DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
all_good = DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
path.char_str(), &CompressCB, &dialog);
else
DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
all_good = DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
path.char_str(),
(iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0,
16384, &CompressCB, &dialog);
}

if (!all_good)
wxMessageBox(_("Dolphin was unable to complete the requested action."));

Update();
}
Expand Down

0 comments on commit 6598462

Please sign in to comment.