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/DiscIO/Src/FileSystemGCWii.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/DiscIO/Src/FileSystemGCWii.cpp')
| -rw-r--r-- | Source/Core/DiscIO/Src/FileSystemGCWii.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp index d5cfa7ae94..8f40ab2f18 100644 --- a/Source/Core/DiscIO/Src/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/Src/FileSystemGCWii.cpp @@ -101,7 +101,7 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi u64 remainingSize = pFileInfo->m_FileSize; u64 fileOffset = pFileInfo->m_Offset; - FILE* f = fopen(_rExportFilename, "wb"); + File::IOFile f(_rExportFilename, "wb"); if (!f) return false; @@ -122,7 +122,7 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi break; } - fwrite(buffer, readSize, 1, f); + f.WriteBytes(buffer, readSize); remainingSize -= readSize; fileOffset += readSize; @@ -130,8 +130,6 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi delete[] buffer; } - fclose(f); - return result; } @@ -147,11 +145,11 @@ bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const { char exportName[512]; sprintf(exportName, "%s/apploader.img", _rExportFolder); - FILE* AppFile = fopen(exportName, "wb"); + + File::IOFile AppFile(exportName, "wb"); if (AppFile) { - fwrite(buffer, AppSize, 1, AppFile); - fclose(AppFile); + AppFile.WriteBytes(buffer, AppSize); delete[] buffer; return true; } @@ -189,11 +187,10 @@ bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const { char exportName[512]; sprintf(exportName, "%s/boot.dol", _rExportFolder); - FILE* DolFile = fopen(exportName, "wb"); + File::IOFile DolFile(exportName, "wb"); if (DolFile) { - fwrite(buffer, DolSize, 1, DolFile); - fclose(DolFile); + DolFile.WriteBytes(buffer, DolSize); delete[] buffer; return true; } |
