From 432084ebe781a4e5e814fa569edc5aca28e63679 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Sat, 30 Aug 2008 22:36:28 +0000 Subject: [PATCH] handled state saving IO errors git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@392 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/State.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 31183e9f72..35e6ca5d44 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -59,6 +59,15 @@ void DoState(PointerWrap &p) void SaveStateCallback(u64 userdata, int cyclesLate) { + static const int chunkSize = 16384; + z_stream strm; + + FILE *f = fopen(cur_filename.c_str(), "wb"); + if(f == NULL) { + Core::DisplayMessage("Could not save state", 2000); + return; + } + Jit64::ClearCache(); u8 *ptr = 0; PointerWrap p(&ptr, PointerWrap::MODE_MEASURE); @@ -68,13 +77,13 @@ void SaveStateCallback(u64 userdata, int cyclesLate) ptr = buffer; p.SetMode(PointerWrap::MODE_WRITE); DoState(p); - FILE *f = fopen(cur_filename.c_str(), "wb"); fwrite(buffer, sz, 1, f); fclose(f); delete [] buffer; - Core::DisplayMessage(StringFromFormat("Saved State to %s", cur_filename.c_str()).c_str(), 2000); + Core::DisplayMessage(StringFromFormat("Saved State to %s", + cur_filename.c_str()).c_str(), 2000); } void LoadStateCallback(u64 userdata, int cyclesLate)