From 6598462aba1e614e1ffb279c8e12976e2dab5b45 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 9 Jan 2013 19:59:31 -0600 Subject: [PATCH] Display error messages when failing to compress/decompress games. Fixes issue 4681. --- Source/Core/DiscIO/Src/CompressedBlob.cpp | 6 +++++- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 24 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Source/Core/DiscIO/Src/CompressedBlob.cpp b/Source/Core/DiscIO/Src/CompressedBlob.cpp index 1e5077b352..48ce8f10f3 100644 --- a/Source/Core/DiscIO/Src/CompressedBlob.cpp +++ b/Source/Core/DiscIO/Src/CompressedBlob.cpp @@ -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(1, header.num_blocks / 100); diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index c67ee83ed3..28051eb390 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -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..."), @@ -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); @@ -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(); } @@ -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..."), @@ -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(); }