mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-29 03:32:54 +00:00
Second attempt at issue 3458. Fixes issue 3458.
Replaces all occurrences of ftell and fseek with ftello and fseeko, respectively. This matters on non-win32 where only these names are altered by the _FILE_OFFSET_BITS define. Win32 still just maps the funcs to ftelli64/fseeki64. Also add some File::GetSize I had skipped in my last commit. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6515 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
97e3a3ea6f
commit
e70e623624
@ -73,8 +73,8 @@ bool WaveFileWriter::Start(const char *filename)
|
|||||||
Write(100 * 1000 * 1000 - 32);
|
Write(100 * 1000 * 1000 - 32);
|
||||||
|
|
||||||
// We are now at offset 44
|
// We are now at offset 44
|
||||||
if (ftell(file) != 44)
|
if (ftello(file) != 44)
|
||||||
PanicAlert("wrong offset: %i", ftell(file));
|
PanicAlert("wrong offset: %i", ftello(file));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -84,11 +84,11 @@ void WaveFileWriter::Stop()
|
|||||||
if (!file)
|
if (!file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// u32 file_size = (u32)ftell(file);
|
// u32 file_size = (u32)ftello(file);
|
||||||
fseek(file, 4, SEEK_SET);
|
fseeko(file, 4, SEEK_SET);
|
||||||
Write(audio_size + 36);
|
Write(audio_size + 36);
|
||||||
|
|
||||||
fseek(file, 40, SEEK_SET);
|
fseeko(file, 40, SEEK_SET);
|
||||||
Write(audio_size);
|
Write(audio_size);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
@ -90,8 +90,8 @@ inline u64 _rotr64(u64 x, unsigned int shift){
|
|||||||
char* strndup (char const *s, size_t n);
|
char* strndup (char const *s, size_t n);
|
||||||
|
|
||||||
// 64 bit offsets for windows
|
// 64 bit offsets for windows
|
||||||
#define fseek _fseeki64
|
#define fseeko _fseeki64
|
||||||
#define ftell _ftelli64
|
#define ftello _ftelli64
|
||||||
#define atoll _atoi64
|
#define atoll _atoi64
|
||||||
#define stat64 _stat64
|
#define stat64 _stat64
|
||||||
#define fstat64 _fstat64
|
#define fstat64 _fstat64
|
||||||
|
@ -56,7 +56,7 @@ bool CheckTitleTMD(u64 _titleID)
|
|||||||
if(pTMDFile)
|
if(pTMDFile)
|
||||||
{
|
{
|
||||||
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
|
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
|
||||||
fseek(pTMDFile, 0x18C, SEEK_SET);
|
fseeko(pTMDFile, 0x18C, SEEK_SET);
|
||||||
fread(&TitleID, 8, 1, pTMDFile);
|
fread(&TitleID, 8, 1, pTMDFile);
|
||||||
fclose(pTMDFile);
|
fclose(pTMDFile);
|
||||||
if (_titleID == Common::swap64(TitleID))
|
if (_titleID == Common::swap64(TitleID))
|
||||||
@ -76,7 +76,7 @@ bool CheckTitleTIK(u64 _titleID)
|
|||||||
if(pTIKFile)
|
if(pTIKFile)
|
||||||
{
|
{
|
||||||
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
|
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
|
||||||
fseek(pTIKFile, 0x1dC, SEEK_SET);
|
fseeko(pTIKFile, 0x1dC, SEEK_SET);
|
||||||
fread(&TitleID, 8, 1, pTIKFile);
|
fread(&TitleID, 8, 1, pTIKFile);
|
||||||
fclose(pTIKFile);
|
fclose(pTIKFile);
|
||||||
if (_titleID == Common::swap64(TitleID))
|
if (_titleID == Common::swap64(TitleID))
|
||||||
|
@ -84,7 +84,7 @@ bool SysConf::LoadFromFileInternal(FILE *f)
|
|||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
||||||
{
|
{
|
||||||
SSysConfEntry& curEntry = m_Entries.at(i);
|
SSysConfEntry& curEntry = m_Entries.at(i);
|
||||||
if (fseek(f, curEntry.offset, SEEK_SET) != 0) return false;
|
if (fseeko(f, curEntry.offset, SEEK_SET) != 0) return false;
|
||||||
|
|
||||||
u8 description = 0;
|
u8 description = 0;
|
||||||
if (fread(&description, sizeof(description), 1, f) != 1) return false;
|
if (fread(&description, sizeof(description), 1, f) != 1) return false;
|
||||||
@ -142,7 +142,7 @@ bool SysConf::SaveToFile(const char *filename)
|
|||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
||||||
{
|
{
|
||||||
// Seek to after the name of this entry
|
// Seek to after the name of this entry
|
||||||
if (fseek(f, m_Entries.at(i).offset + m_Entries.at(i).nameLength + 1, SEEK_SET) != 0) return false;
|
if (fseeko(f, m_Entries.at(i).offset + m_Entries.at(i).nameLength + 1, SEEK_SET) != 0) return false;
|
||||||
// We may have to write array length value...
|
// We may have to write array length value...
|
||||||
if (m_Entries.at(i).type == Type_BigArray)
|
if (m_Entries.at(i).type == Type_BigArray)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@ bool CDolLoader::IsDolWii(const char* filename)
|
|||||||
FILE* pStream = fopen(filename, "rb");
|
FILE* pStream = fopen(filename, "rb");
|
||||||
if (pStream)
|
if (pStream)
|
||||||
{
|
{
|
||||||
fseek(pStream, 0xe0, SEEK_SET);
|
fseeko(pStream, 0xe0, SEEK_SET);
|
||||||
u32 entrypt = fgetc(pStream) << 24 | fgetc(pStream) << 16 |
|
u32 entrypt = fgetc(pStream) << 24 | fgetc(pStream) << 16 |
|
||||||
fgetc(pStream) << 8 | fgetc(pStream);
|
fgetc(pStream) << 8 | fgetc(pStream);
|
||||||
|
|
||||||
|
@ -228,9 +228,7 @@ void CEXIIPL::LoadFileToIPL(std::string filename, u32 offset)
|
|||||||
FILE* pStream = fopen(filename.c_str(), "rb");
|
FILE* pStream = fopen(filename.c_str(), "rb");
|
||||||
if (pStream != NULL)
|
if (pStream != NULL)
|
||||||
{
|
{
|
||||||
fseek(pStream, 0, SEEK_END);
|
u64 filesize = File::GetSize(pStream);
|
||||||
size_t filesize = (size_t)ftell(pStream);
|
|
||||||
rewind(pStream);
|
|
||||||
|
|
||||||
fread(m_pIPL + offset, 1, filesize, pStream);
|
fread(m_pIPL + offset, 1, filesize, pStream);
|
||||||
fclose(pStream);
|
fclose(pStream);
|
||||||
|
@ -77,11 +77,7 @@ CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rF
|
|||||||
if (pFile)
|
if (pFile)
|
||||||
{
|
{
|
||||||
// Measure size of the memcard file.
|
// Measure size of the memcard file.
|
||||||
fseek(pFile, 0L, SEEK_END);
|
memory_card_size = (int)File::GetSize(pFile);
|
||||||
u64 MemFileSize = ftell(pFile);
|
|
||||||
fseek(pFile, 0L, SEEK_SET);
|
|
||||||
|
|
||||||
memory_card_size = (int)MemFileSize;
|
|
||||||
nintendo_card_id = memory_card_size / SIZE_TO_Mb;
|
nintendo_card_id = memory_card_size / SIZE_TO_Mb;
|
||||||
memory_card_content = new u8[memory_card_size];
|
memory_card_content = new u8[memory_card_size];
|
||||||
memset(memory_card_content, 0xFF, memory_card_size);
|
memset(memory_card_content, 0xFF, memory_card_size);
|
||||||
|
@ -163,9 +163,9 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
|
|||||||
|
|
||||||
if (Mode >= 0 && Mode <= 2)
|
if (Mode >= 0 && Mode <= 2)
|
||||||
{
|
{
|
||||||
if (fseek(m_pFileHandle, NewSeekPosition, seek_mode[Mode]) == 0)
|
if (fseeko(m_pFileHandle, NewSeekPosition, seek_mode[Mode]) == 0)
|
||||||
{
|
{
|
||||||
ReturnValue = (u32)ftell(m_pFileHandle);
|
ReturnValue = (u32)ftello(m_pFileHandle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -243,7 +243,7 @@ bool CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
|
|||||||
case ISFS_IOCTL_GETFILESTATS:
|
case ISFS_IOCTL_GETFILESTATS:
|
||||||
{
|
{
|
||||||
m_FileLength = (u32)File::GetSize(m_Filename.c_str());
|
m_FileLength = (u32)File::GetSize(m_Filename.c_str());
|
||||||
u32 Position = (u32)ftell(m_pFileHandle);
|
u32 Position = (u32)ftello(m_pFileHandle);
|
||||||
|
|
||||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
||||||
INFO_LOG(WII_IPC_FILEIO, "FileIO: ISFS_IOCTL_GETFILESTATS");
|
INFO_LOG(WII_IPC_FILEIO, "FileIO: ISFS_IOCTL_GETFILESTATS");
|
||||||
@ -278,7 +278,7 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap &p)
|
|||||||
{
|
{
|
||||||
if (p.GetMode() == PointerWrap::MODE_WRITE)
|
if (p.GetMode() == PointerWrap::MODE_WRITE)
|
||||||
{
|
{
|
||||||
m_Seek = (m_pFileHandle) ? (s32)ftell(m_pFileHandle) : 0;
|
m_Seek = (m_pFileHandle) ? (s32)ftello(m_pFileHandle) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.Do(m_Mode);
|
p.Do(m_Mode);
|
||||||
@ -290,7 +290,7 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap &p)
|
|||||||
{
|
{
|
||||||
Open(0, m_Mode);
|
Open(0, m_Mode);
|
||||||
if (m_pFileHandle)
|
if (m_pFileHandle)
|
||||||
fseek(m_pFileHandle, m_Seek, SEEK_SET);
|
fseeko(m_pFileHandle, m_Seek, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,8 +344,8 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS
|
|||||||
{
|
{
|
||||||
u32 size = req.bsize * req.blocks;
|
u32 size = req.bsize * req.blocks;
|
||||||
|
|
||||||
if (fseek(m_Card, req.arg, SEEK_SET) != 0)
|
if (fseeko(m_Card, req.arg, SEEK_SET) != 0)
|
||||||
ERROR_LOG(WII_IPC_SD, "fseek failed WTF");
|
ERROR_LOG(WII_IPC_SD, "fseeko failed WTF");
|
||||||
|
|
||||||
u8* buffer = new u8[size];
|
u8* buffer = new u8[size];
|
||||||
|
|
||||||
@ -383,8 +383,8 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(u32 _BufferIn, u32 _BufferInS
|
|||||||
{
|
{
|
||||||
u32 size = req.bsize * req.blocks;
|
u32 size = req.bsize * req.blocks;
|
||||||
|
|
||||||
if (fseek(m_Card, req.arg, SEEK_SET) != 0)
|
if (fseeko(m_Card, req.arg, SEEK_SET) != 0)
|
||||||
ERROR_LOG(WII_IPC_SD, "fseek failed WTF");
|
ERROR_LOG(WII_IPC_SD, "fseeko failed WTF");
|
||||||
|
|
||||||
u8* buffer = new u8[size];
|
u8* buffer = new u8[size];
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void LoadInput(const char *filename)
|
|||||||
File::Copy(filename, g_recordFile.c_str());
|
File::Copy(filename, g_recordFile.c_str());
|
||||||
|
|
||||||
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
|
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
|
||||||
fseek(g_recordfd, 0, SEEK_END);
|
fseeko(g_recordfd, 0, SEEK_END);
|
||||||
|
|
||||||
g_rerecords++;
|
g_rerecords++;
|
||||||
|
|
||||||
@ -469,6 +469,6 @@ void SaveRecording(const char *filename)
|
|||||||
Core::DisplayMessage(StringFromFormat("Failed to save %s", filename).c_str(), 2000);
|
Core::DisplayMessage(StringFromFormat("Failed to save %s", filename).c_str(), 2000);
|
||||||
|
|
||||||
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
|
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
|
||||||
fseek(g_recordfd, 0, SEEK_END);
|
fseeko(g_recordfd, 0, SEEK_END);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -108,7 +108,7 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
|
|||||||
// clear unused part of zlib buffer. maybe this can be deleted when it works fully.
|
// clear unused part of zlib buffer. maybe this can be deleted when it works fully.
|
||||||
memset(zlib_buffer + comp_block_size, 0, zlib_buffer_size - comp_block_size);
|
memset(zlib_buffer + comp_block_size, 0, zlib_buffer_size - comp_block_size);
|
||||||
|
|
||||||
fseek(file, offset, SEEK_SET);
|
fseeko(file, offset, SEEK_SET);
|
||||||
fread(zlib_buffer, 1, comp_block_size, file);
|
fread(zlib_buffer, 1, comp_block_size, file);
|
||||||
|
|
||||||
u8* source = zlib_buffer;
|
u8* source = zlib_buffer;
|
||||||
@ -203,9 +203,9 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
|
|||||||
u8* in_buf = new u8[block_size];
|
u8* in_buf = new u8[block_size];
|
||||||
|
|
||||||
// seek past the header (we will write it at the end)
|
// seek past the header (we will write it at the end)
|
||||||
fseek(f, sizeof(CompressedBlobHeader), SEEK_CUR);
|
fseeko(f, sizeof(CompressedBlobHeader), SEEK_CUR);
|
||||||
// seek past the offset and hash tables (we will write them at the end)
|
// seek past the offset and hash tables (we will write them at the end)
|
||||||
fseek(f, (sizeof(u64) + sizeof(u32)) * header.num_blocks, SEEK_CUR);
|
fseeko(f, (sizeof(u64) + sizeof(u32)) * header.num_blocks, SEEK_CUR);
|
||||||
|
|
||||||
// Now we are ready to write compressed data!
|
// Now we are ready to write compressed data!
|
||||||
u64 position = 0;
|
u64 position = 0;
|
||||||
@ -217,7 +217,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
|
|||||||
{
|
{
|
||||||
if (i % progress_monitor == 0)
|
if (i % progress_monitor == 0)
|
||||||
{
|
{
|
||||||
u64 inpos = ftell(inf);
|
u64 inpos = ftello(inf);
|
||||||
int ratio = 0;
|
int ratio = 0;
|
||||||
if (inpos != 0)
|
if (inpos != 0)
|
||||||
ratio = (int)(100 * position / inpos);
|
ratio = (int)(100 * position / inpos);
|
||||||
@ -279,7 +279,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
|
|||||||
header.compressed_data_size = position;
|
header.compressed_data_size = position;
|
||||||
|
|
||||||
// Okay, go back and fill in headers
|
// Okay, go back and fill in headers
|
||||||
fseek(f, 0, SEEK_SET);
|
fseeko(f, 0, SEEK_SET);
|
||||||
fwrite(&header, sizeof(header), 1, f);
|
fwrite(&header, sizeof(header), 1, f);
|
||||||
fwrite(offsets, sizeof(u64), header.num_blocks, f);
|
fwrite(offsets, sizeof(u64), header.num_blocks, f);
|
||||||
fwrite(hashes, sizeof(u32), header.num_blocks, f);
|
fwrite(hashes, sizeof(u32), header.num_blocks, f);
|
||||||
|
@ -138,7 +138,7 @@ void GetNextBlock(FILE* in, u8* buffer)
|
|||||||
{
|
{
|
||||||
DEBUG_LOG(DISCIO, "Freeing 0x%016llx", CurrentOffset);
|
DEBUG_LOG(DISCIO, "Freeing 0x%016llx", CurrentOffset);
|
||||||
std::fill(buffer, buffer + m_BlockSize, 0xFF);
|
std::fill(buffer, buffer + m_BlockSize, 0xFF);
|
||||||
fseek(in, m_BlockSize, SEEK_CUR);
|
fseeko(in, m_BlockSize, SEEK_CUR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
|
|||||||
if (!ReadFile(hDisc, lpSector, m_blocksize, (LPDWORD)&NotUsed, NULL))
|
if (!ReadFile(hDisc, lpSector, m_blocksize, (LPDWORD)&NotUsed, NULL))
|
||||||
PanicAlert("Disc Read Error");
|
PanicAlert("Disc Read Error");
|
||||||
#else
|
#else
|
||||||
fseek(file_, m_blocksize*block_num, SEEK_SET);
|
fseeko(file_, m_blocksize*block_num, SEEK_SET);
|
||||||
fread(lpSector, 1, m_blocksize, file_);
|
fread(lpSector, 1, m_blocksize, file_);
|
||||||
#endif
|
#endif
|
||||||
memcpy(out_ptr, lpSector, m_blocksize);
|
memcpy(out_ptr, lpSector, m_blocksize);
|
||||||
@ -132,7 +132,7 @@ bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *o
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fseek(file_, m_blocksize*block_num, SEEK_SET);
|
fseeko(file_, m_blocksize*block_num, SEEK_SET);
|
||||||
if(fread(out_ptr, 1, m_blocksize * num_blocks, file_) != m_blocksize * num_blocks)
|
if(fread(out_ptr, 1, m_blocksize * num_blocks, file_) != m_blocksize * num_blocks)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,7 +46,7 @@ PlainFileReader::~PlainFileReader()
|
|||||||
|
|
||||||
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
||||||
{
|
{
|
||||||
int seekStatus = fseek(file_, offset, SEEK_SET);
|
int seekStatus = fseeko(file_, offset, SEEK_SET);
|
||||||
if (seekStatus != 0)
|
if (seekStatus != 0)
|
||||||
return false;
|
return false;
|
||||||
size_t bytesRead = fread(out_ptr, 1, nbytes, file_);
|
size_t bytesRead = fread(out_ptr, 1, nbytes, file_);
|
||||||
|
@ -65,7 +65,7 @@ LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
|
|||||||
|
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
fopen_s(&file, "exceptioninfo.txt", "a");
|
fopen_s(&file, "exceptioninfo.txt", "a");
|
||||||
fseek(file, 0, SEEK_END);
|
fseeko(file, 0, SEEK_END);
|
||||||
etfprint(file, "\n");
|
etfprint(file, "\n");
|
||||||
//etfprint(file, g_buildtime);
|
//etfprint(file, g_buildtime);
|
||||||
//etfprint(file, "\n");
|
//etfprint(file, "\n");
|
||||||
|
@ -100,7 +100,7 @@ GCMemcard::GCMemcard(const char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(mcd, 0, SEEK_SET);
|
fseeko(mcd, 0, SEEK_SET);
|
||||||
if (fread(&hdr, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE)
|
if (fread(&hdr, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE)
|
||||||
{
|
{
|
||||||
fail = true;
|
fail = true;
|
||||||
@ -191,7 +191,7 @@ GCMemcard::GCMemcard(const char *filename)
|
|||||||
// bat = bat_backup; // needed?
|
// bat = bat_backup; // needed?
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(mcd, 0xa000, SEEK_SET);
|
fseeko(mcd, 0xa000, SEEK_SET);
|
||||||
|
|
||||||
u16 sizeMb = BE16(hdr.SizeMb);
|
u16 sizeMb = BE16(hdr.SizeMb);
|
||||||
switch (sizeMb)
|
switch (sizeMb)
|
||||||
@ -241,7 +241,7 @@ bool GCMemcard::Save()
|
|||||||
{
|
{
|
||||||
bool completeWrite = true;
|
bool completeWrite = true;
|
||||||
FILE *mcd=(FILE*)mcdFile;
|
FILE *mcd=(FILE*)mcdFile;
|
||||||
fseek(mcd, 0, SEEK_SET);
|
fseeko(mcd, 0, SEEK_SET);
|
||||||
if (fwrite(&hdr, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE) completeWrite = false;
|
if (fwrite(&hdr, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE) completeWrite = false;
|
||||||
if (fwrite(&dir, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE) completeWrite = false;
|
if (fwrite(&dir, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE) completeWrite = false;
|
||||||
if (fwrite(&dir_backup, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE) completeWrite = false;
|
if (fwrite(&dir_backup, 1, BLOCK_SIZE, mcd) != BLOCK_SIZE) completeWrite = false;
|
||||||
@ -816,20 +816,20 @@ u32 GCMemcard::ImportGciInternal(FILE *gci, const char *inputFile, std::string o
|
|||||||
else
|
else
|
||||||
return OPENFAIL;
|
return OPENFAIL;
|
||||||
}
|
}
|
||||||
fseek(gci, offset, SEEK_SET);
|
fseeko(gci, offset, SEEK_SET);
|
||||||
|
|
||||||
DEntry *tempDEntry = new DEntry;
|
DEntry *tempDEntry = new DEntry;
|
||||||
fread(tempDEntry, 1, DENTRY_SIZE, gci);
|
fread(tempDEntry, 1, DENTRY_SIZE, gci);
|
||||||
int fStart = (int) ftell(gci);
|
int fStart = (int) ftello(gci);
|
||||||
fseek(gci, 0, SEEK_END);
|
fseeko(gci, 0, SEEK_END);
|
||||||
int length = (int) ftell(gci) - fStart;
|
int length = (int) ftello(gci) - fStart;
|
||||||
fseek(gci, offset + DENTRY_SIZE, SEEK_SET);
|
fseeko(gci, offset + DENTRY_SIZE, SEEK_SET);
|
||||||
|
|
||||||
Gcs_SavConvert(tempDEntry, offset, length);
|
Gcs_SavConvert(tempDEntry, offset, length);
|
||||||
|
|
||||||
if (length != BE16(tempDEntry->BlockCount) * BLOCK_SIZE)
|
if (length != BE16(tempDEntry->BlockCount) * BLOCK_SIZE)
|
||||||
return LENGTHFAIL;
|
return LENGTHFAIL;
|
||||||
if (ftell(gci) != offset + DENTRY_SIZE) // Verify correct file position
|
if (ftello(gci) != offset + DENTRY_SIZE) // Verify correct file position
|
||||||
return OPENFAIL;
|
return OPENFAIL;
|
||||||
|
|
||||||
u32 size = BE16((tempDEntry->BlockCount)) * BLOCK_SIZE;
|
u32 size = BE16((tempDEntry->BlockCount)) * BLOCK_SIZE;
|
||||||
@ -846,12 +846,12 @@ u32 GCMemcard::ImportGciInternal(FILE *gci, const char *inputFile, std::string o
|
|||||||
delete tempDEntry;
|
delete tempDEntry;
|
||||||
return OPENFAIL;
|
return OPENFAIL;
|
||||||
}
|
}
|
||||||
fseek(gci2, 0, SEEK_SET);
|
fseeko(gci2, 0, SEEK_SET);
|
||||||
|
|
||||||
if (fwrite(tempDEntry, 1, DENTRY_SIZE, gci2) != DENTRY_SIZE)
|
if (fwrite(tempDEntry, 1, DENTRY_SIZE, gci2) != DENTRY_SIZE)
|
||||||
completeWrite = false;
|
completeWrite = false;
|
||||||
int fileBlocks = BE16(tempDEntry->BlockCount);
|
int fileBlocks = BE16(tempDEntry->BlockCount);
|
||||||
fseek(gci2, DENTRY_SIZE, SEEK_SET);
|
fseeko(gci2, DENTRY_SIZE, SEEK_SET);
|
||||||
|
|
||||||
if (fwrite(tempSaveData, 1, BLOCK_SIZE * fileBlocks, gci2) != (unsigned)(BLOCK_SIZE * fileBlocks))
|
if (fwrite(tempSaveData, 1, BLOCK_SIZE * fileBlocks, gci2) != (unsigned)(BLOCK_SIZE * fileBlocks))
|
||||||
completeWrite = false;
|
completeWrite = false;
|
||||||
@ -904,7 +904,7 @@ u32 GCMemcard::ExportGci(u8 index, const char *fileName, std::string *fileName2)
|
|||||||
if (!gci) return OPENFAIL;
|
if (!gci) return OPENFAIL;
|
||||||
bool completeWrite = true;
|
bool completeWrite = true;
|
||||||
|
|
||||||
fseek(gci, 0, SEEK_SET);
|
fseeko(gci, 0, SEEK_SET);
|
||||||
|
|
||||||
switch(offset)
|
switch(offset)
|
||||||
{
|
{
|
||||||
@ -953,7 +953,7 @@ u32 GCMemcard::ExportGci(u8 index, const char *fileName, std::string *fileName2)
|
|||||||
delete[] tempSaveData;
|
delete[] tempSaveData;
|
||||||
return NOMEMCARD;
|
return NOMEMCARD;
|
||||||
}
|
}
|
||||||
fseek(gci, DENTRY_SIZE + offset, SEEK_SET);
|
fseeko(gci, DENTRY_SIZE + offset, SEEK_SET);
|
||||||
if (fwrite(tempSaveData, 1, size, gci) != size)
|
if (fwrite(tempSaveData, 1, size, gci) != size)
|
||||||
completeWrite = false;
|
completeWrite = false;
|
||||||
fclose(gci);
|
fclose(gci);
|
||||||
|
@ -185,7 +185,7 @@ void CWiiSaveCrypted::ReadBKHDR()
|
|||||||
b_valid = false;
|
b_valid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fseek(fpData_bin, HEADER_SZ, SEEK_SET);
|
fseeko(fpData_bin, HEADER_SZ, SEEK_SET);
|
||||||
if (fread(&bkhdr, BK_SZ, 1, fpData_bin) != 1)
|
if (fread(&bkhdr, BK_SZ, 1, fpData_bin) != 1)
|
||||||
{
|
{
|
||||||
PanicAlert("failed to read bk header");
|
PanicAlert("failed to read bk header");
|
||||||
@ -267,7 +267,7 @@ void CWiiSaveCrypted::ImportWiiSaveFiles()
|
|||||||
|
|
||||||
for(u32 i = 0; i < _numberOfFiles; i++)
|
for(u32 i = 0; i < _numberOfFiles; i++)
|
||||||
{
|
{
|
||||||
fseek(fpData_bin, lastpos, SEEK_SET);
|
fseeko(fpData_bin, lastpos, SEEK_SET);
|
||||||
memset(&_tmpFileHDR, 0, FILE_HDR_SZ);
|
memset(&_tmpFileHDR, 0, FILE_HDR_SZ);
|
||||||
memset(IV, 0, 0x10);
|
memset(IV, 0, 0x10);
|
||||||
_fileSize = 0;
|
_fileSize = 0;
|
||||||
@ -450,7 +450,7 @@ void CWiiSaveCrypted::do_sig()
|
|||||||
}
|
}
|
||||||
data = new u8[data_size];
|
data = new u8[data_size];
|
||||||
|
|
||||||
fseek(fpData_bin, 0xf0c0, SEEK_SET);
|
fseeko(fpData_bin, 0xf0c0, SEEK_SET);
|
||||||
if (fread(data, data_size, 1, fpData_bin) != 1)
|
if (fread(data, data_size, 1, fpData_bin) != 1)
|
||||||
PanicAlert("read data for sig check");
|
PanicAlert("read data for sig check");
|
||||||
sha1(data, data_size, hash);
|
sha1(data, data_size, hash);
|
||||||
|
@ -106,9 +106,9 @@ bool ReadFileToString(bool text_file, const char *filename, std::string &str)
|
|||||||
FILE *f = fopen(filename, text_file ? "r" : "rb");
|
FILE *f = fopen(filename, text_file ? "r" : "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
fseek(f, 0, SEEK_END);
|
fseeko(f, 0, SEEK_END);
|
||||||
size_t len = ftell(f);
|
size_t len = ftello(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseeko(f, 0, SEEK_SET);
|
||||||
char *buf = new char[len + 1];
|
char *buf = new char[len + 1];
|
||||||
buf[fread(buf, 1, len, f)] = 0;
|
buf[fread(buf, 1, len, f)] = 0;
|
||||||
str = std::string(buf, len);
|
str = std::string(buf, len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user