mirror of https://github.com/PCSX2/pcsx2.git
Better seeking for IsoFile; using s64 to allow for a full 4gb of addressable file positions in either direction.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2166 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
c6b14bd7f0
commit
b562e8aa0f
|
@ -59,21 +59,23 @@ u32 IsoFile::seek(u32 absoffset)
|
||||||
return currentOffset;
|
return currentOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 IsoFile::seek(s32 offset, wxSeekMode ref_position)
|
// Returns the new offset in the file. Out-of-bounds seeks are automatically truncated at 0
|
||||||
|
// and fileLength.
|
||||||
|
u32 IsoFile::seek(s64 offset, wxSeekMode ref_position)
|
||||||
{
|
{
|
||||||
switch( ref_position )
|
switch( ref_position )
|
||||||
{
|
{
|
||||||
case wxFromStart:
|
case wxFromStart:
|
||||||
pxAssertDev( offset > 0, "Invalid seek position from start." );
|
pxAssertDev( offset >= 0 && offset <= (s64)ULONG_MAX, "Invalid seek position from start." );
|
||||||
return seek(offset);
|
return seek(offset);
|
||||||
|
|
||||||
case wxFromCurrent:
|
case wxFromCurrent:
|
||||||
// truncate negative values to zero
|
// truncate negative values to zero, and positive values to 4gb
|
||||||
return seek( std::max<u32>(0, currentOffset+offset) );
|
return seek( std::min( std::max<s64>(0, (s64)currentOffset+offset), (s64)ULONG_MAX ) );
|
||||||
|
|
||||||
case wxFromEnd:
|
case wxFromEnd:
|
||||||
// truncate negative values to zero
|
// truncate negative values to zero, and positive values to 4gb
|
||||||
return seek( std::max<u32>(0, fileEntry.size+offset) );
|
return seek( std::min( std::max<s64>(0, (s64)fileEntry.size+offset), (s64)ULONG_MAX ) );
|
||||||
|
|
||||||
jNO_DEFAULT;
|
jNO_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
virtual ~IsoFile() throw();
|
virtual ~IsoFile() throw();
|
||||||
|
|
||||||
u32 seek(u32 absoffset);
|
u32 seek(u32 absoffset);
|
||||||
u32 seek(s32 offset, wxSeekMode ref_position);
|
u32 seek(s64 offset, wxSeekMode ref_position);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
s32 skip(s32 n);
|
s32 skip(s32 n);
|
||||||
|
|
Loading…
Reference in New Issue