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:
Shawn Hoffman
2010-12-04 03:50:55 +00:00
parent 97e3a3ea6f
commit e70e623624
18 changed files with 54 additions and 60 deletions

View File

@ -65,7 +65,7 @@ LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
FILE* file = NULL;
fopen_s(&file, "exceptioninfo.txt", "a");
fseek(file, 0, SEEK_END);
fseeko(file, 0, SEEK_END);
etfprint(file, "\n");
//etfprint(file, g_buildtime);
//etfprint(file, "\n");

View File

@ -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)
{
fail = true;
@ -191,7 +191,7 @@ GCMemcard::GCMemcard(const char *filename)
// bat = bat_backup; // needed?
}
fseek(mcd, 0xa000, SEEK_SET);
fseeko(mcd, 0xa000, SEEK_SET);
u16 sizeMb = BE16(hdr.SizeMb);
switch (sizeMb)
@ -241,7 +241,7 @@ bool GCMemcard::Save()
{
bool completeWrite = true;
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(&dir, 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
return OPENFAIL;
}
fseek(gci, offset, SEEK_SET);
fseeko(gci, offset, SEEK_SET);
DEntry *tempDEntry = new DEntry;
fread(tempDEntry, 1, DENTRY_SIZE, gci);
int fStart = (int) ftell(gci);
fseek(gci, 0, SEEK_END);
int length = (int) ftell(gci) - fStart;
fseek(gci, offset + DENTRY_SIZE, SEEK_SET);
int fStart = (int) ftello(gci);
fseeko(gci, 0, SEEK_END);
int length = (int) ftello(gci) - fStart;
fseeko(gci, offset + DENTRY_SIZE, SEEK_SET);
Gcs_SavConvert(tempDEntry, offset, length);
if (length != BE16(tempDEntry->BlockCount) * BLOCK_SIZE)
return LENGTHFAIL;
if (ftell(gci) != offset + DENTRY_SIZE) // Verify correct file position
if (ftello(gci) != offset + DENTRY_SIZE) // Verify correct file position
return OPENFAIL;
u32 size = BE16((tempDEntry->BlockCount)) * BLOCK_SIZE;
@ -846,12 +846,12 @@ u32 GCMemcard::ImportGciInternal(FILE *gci, const char *inputFile, std::string o
delete tempDEntry;
return OPENFAIL;
}
fseek(gci2, 0, SEEK_SET);
fseeko(gci2, 0, SEEK_SET);
if (fwrite(tempDEntry, 1, DENTRY_SIZE, gci2) != DENTRY_SIZE)
completeWrite = false;
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))
completeWrite = false;
@ -904,7 +904,7 @@ u32 GCMemcard::ExportGci(u8 index, const char *fileName, std::string *fileName2)
if (!gci) return OPENFAIL;
bool completeWrite = true;
fseek(gci, 0, SEEK_SET);
fseeko(gci, 0, SEEK_SET);
switch(offset)
{
@ -953,7 +953,7 @@ u32 GCMemcard::ExportGci(u8 index, const char *fileName, std::string *fileName2)
delete[] tempSaveData;
return NOMEMCARD;
}
fseek(gci, DENTRY_SIZE + offset, SEEK_SET);
fseeko(gci, DENTRY_SIZE + offset, SEEK_SET);
if (fwrite(tempSaveData, 1, size, gci) != size)
completeWrite = false;
fclose(gci);

View File

@ -185,7 +185,7 @@ void CWiiSaveCrypted::ReadBKHDR()
b_valid = false;
return;
}
fseek(fpData_bin, HEADER_SZ, SEEK_SET);
fseeko(fpData_bin, HEADER_SZ, SEEK_SET);
if (fread(&bkhdr, BK_SZ, 1, fpData_bin) != 1)
{
PanicAlert("failed to read bk header");
@ -267,7 +267,7 @@ void CWiiSaveCrypted::ImportWiiSaveFiles()
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(IV, 0, 0x10);
_fileSize = 0;
@ -450,7 +450,7 @@ void CWiiSaveCrypted::do_sig()
}
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)
PanicAlert("read data for sig check");
sha1(data, data_size, hash);