mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Actually export 0-sized files.
Fixes issue 5177.
This commit is contained in:
parent
d9ea718559
commit
32855a289c
@ -19,6 +19,7 @@
|
|||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "FileSystemGCWii.h"
|
#include "FileSystemGCWii.h"
|
||||||
#include "StringUtil.h"
|
#include "StringUtil.h"
|
||||||
@ -95,7 +96,7 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi
|
|||||||
|
|
||||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||||
|
|
||||||
if (!pFileInfo || pFileInfo->m_FileSize == 0)
|
if (!pFileInfo)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
u64 remainingSize = pFileInfo->m_FileSize;
|
u64 remainingSize = pFileInfo->m_FileSize;
|
||||||
@ -112,22 +113,17 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi
|
|||||||
// Limit read size to 128 MB
|
// Limit read size to 128 MB
|
||||||
size_t readSize = (size_t)min(remainingSize, (u64)0x08000000);
|
size_t readSize = (size_t)min(remainingSize, (u64)0x08000000);
|
||||||
|
|
||||||
u8* buffer = new u8[readSize];
|
std::vector<u8> buffer(readSize);
|
||||||
|
|
||||||
result = m_rVolume->Read(fileOffset, readSize, buffer);
|
result = m_rVolume->Read(fileOffset, readSize, &buffer[0]);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
|
||||||
delete[] buffer;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
f.WriteBytes(buffer, readSize);
|
f.WriteBytes(&buffer[0], readSize);
|
||||||
|
|
||||||
remainingSize -= readSize;
|
remainingSize -= readSize;
|
||||||
fileOffset += readSize;
|
fileOffset += readSize;
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -140,22 +136,20 @@ bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const
|
|||||||
AppSize += 0x20; // + header size
|
AppSize += 0x20; // + header size
|
||||||
DEBUG_LOG(DISCIO,"AppSize -> %x", AppSize);
|
DEBUG_LOG(DISCIO,"AppSize -> %x", AppSize);
|
||||||
|
|
||||||
u8* buffer = new u8[AppSize];
|
std::vector<u8> buffer(AppSize);
|
||||||
if (m_rVolume->Read(0x2440, AppSize, buffer))
|
if (m_rVolume->Read(0x2440, AppSize, &buffer[0]))
|
||||||
{
|
{
|
||||||
char exportName[512];
|
std::string exportName(_rExportFolder);
|
||||||
sprintf(exportName, "%s/apploader.img", _rExportFolder);
|
exportName += "/apploader.img";
|
||||||
|
|
||||||
File::IOFile AppFile(exportName, "wb");
|
File::IOFile AppFile(exportName, "wb");
|
||||||
if (AppFile)
|
if (AppFile)
|
||||||
{
|
{
|
||||||
AppFile.WriteBytes(buffer, AppSize);
|
AppFile.WriteBytes(&buffer[0], AppSize);
|
||||||
delete[] buffer;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,21 +176,20 @@ bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const
|
|||||||
DolSize = offset + size;
|
DolSize = offset + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* buffer = new u8[DolSize];
|
std::vector<u8> buffer(DolSize);
|
||||||
if (m_rVolume->Read(DolOffset, DolSize, buffer))
|
if (m_rVolume->Read(DolOffset, DolSize, &buffer[0]))
|
||||||
{
|
{
|
||||||
char exportName[512];
|
std::string exportName(_rExportFolder);
|
||||||
sprintf(exportName, "%s/boot.dol", _rExportFolder);
|
exportName += "/boot.dol";
|
||||||
|
|
||||||
File::IOFile DolFile(exportName, "wb");
|
File::IOFile DolFile(exportName, "wb");
|
||||||
if (DolFile)
|
if (DolFile)
|
||||||
{
|
{
|
||||||
DolFile.WriteBytes(buffer, DolSize);
|
DolFile.WriteBytes(&buffer[0], DolSize);
|
||||||
delete[] buffer;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user