diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2011-03-11 10:21:46 +0000 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2011-03-11 10:21:46 +0000 |
| commit | 59fd1008ca9cf4e9f75fdd6ee8ec53a2c7d7a13b (patch) | |
| tree | 1de127fb452967ccc052324d9aff0775ea1b76cf /Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp | |
| parent | 4f69672b2b31581746aae907e7757981fc48db77 (diff) | |
Wrapped fopen/close/read/write functions inside a simple "IOFile" class. Reading, writing, and error checking became simpler in most cases. It should be near impossible to forget to close a file now that the destructor takes care of it. (I hope this fixes Issue 3635) I have tested the functionality of most things, but it is possible I broke something. :p
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7328 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp index c0c3665c46..160066b1b5 100644 --- a/Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Src/Debugger/MemoryWindow.cpp @@ -228,40 +228,31 @@ void CMemoryWindow::OnHostMessage(wxCommandEvent& event) } } -// Write mram to file -void CMemoryWindow::OnDumpMemory( wxCommandEvent& event ) +void DumpArray(const std::string& filename, const u8* data, size_t length) { - FILE* f = fopen(File::GetUserPath(F_RAMDUMP_IDX).c_str(), "wb"); - if (f && Memory::m_pRAM) + if (data) { - fwrite(Memory::m_pRAM, Memory::REALRAM_SIZE, 1, f); - fclose(f); + File::IOFile f(filename, "wb"); + f.WriteBytes(data, length); } } +// Write mram to file +void CMemoryWindow::OnDumpMemory( wxCommandEvent& event ) +{ + DumpArray(File::GetUserPath(F_RAMDUMP_IDX), Memory::m_pRAM, Memory::REALRAM_SIZE); +} + // Write exram (aram or mem2) to file void CMemoryWindow::OnDumpMem2( wxCommandEvent& event ) -{ - FILE* f = NULL; - +{ if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) { - f = fopen(File::GetUserPath(F_ARAMDUMP_IDX).c_str(), "wb"); - if (f && Memory::m_pEXRAM) - { - fwrite(Memory::m_pEXRAM, Memory::EXRAM_SIZE, 1, f); - fclose(f); - } + DumpArray(File::GetUserPath(F_ARAMDUMP_IDX), Memory::m_pEXRAM, Memory::EXRAM_SIZE); } else { - u8* aram = DSP::GetARAMPtr(); - f = fopen(File::GetUserPath(F_ARAMDUMP_IDX).c_str(), "wb"); - if (f && aram) - { - fwrite(aram, DSP::ARAM_SIZE, 1, f); - fclose(f); - } + DumpArray(File::GetUserPath(F_ARAMDUMP_IDX), DSP::GetARAMPtr(), DSP::ARAM_SIZE); } } |
