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

@ -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.
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);
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];
// 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)
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!
u64 position = 0;
@ -217,7 +217,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
{
if (i % progress_monitor == 0)
{
u64 inpos = ftell(inf);
u64 inpos = ftello(inf);
int ratio = 0;
if (inpos != 0)
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;
// Okay, go back and fill in headers
fseek(f, 0, SEEK_SET);
fseeko(f, 0, SEEK_SET);
fwrite(&header, sizeof(header), 1, f);
fwrite(offsets, sizeof(u64), header.num_blocks, f);
fwrite(hashes, sizeof(u32), header.num_blocks, f);

View File

@ -138,7 +138,7 @@ void GetNextBlock(FILE* in, u8* buffer)
{
DEBUG_LOG(DISCIO, "Freeing 0x%016llx", CurrentOffset);
std::fill(buffer, buffer + m_BlockSize, 0xFF);
fseek(in, m_BlockSize, SEEK_CUR);
fseeko(in, m_BlockSize, SEEK_CUR);
}
else
{

View File

@ -111,7 +111,7 @@ void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
if (!ReadFile(hDisc, lpSector, m_blocksize, (LPDWORD)&NotUsed, NULL))
PanicAlert("Disc Read Error");
#else
fseek(file_, m_blocksize*block_num, SEEK_SET);
fseeko(file_, m_blocksize*block_num, SEEK_SET);
fread(lpSector, 1, m_blocksize, file_);
#endif
memcpy(out_ptr, lpSector, m_blocksize);
@ -132,7 +132,7 @@ bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *o
return false;
}
#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)
return false;
#endif

View File

@ -46,7 +46,7 @@ PlainFileReader::~PlainFileReader()
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)
return false;
size_t bytesRead = fread(out_ptr, 1, nbytes, file_);