mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user