TStream.Seek(Int64) problem in Delphi XE2

TStream.Seek(Int64) problem in Delphi XE2

I've just discovered a condition in which I'm sending a INT64 value to a variable of type TStream, but it seems to use a 32-bit version of the function?

Specifically, When I use TStream.Seek(MyInt64, soFromBeginning) it seems to be calling the 32-bit version of the function and "eff'ing" up the seek when the value is over 32-bit.  I've swapped it to use the TStream.Position property and it seems to use the 64-bit correctly.

Any idea why?

Stack Trace URL added for more documentation.

== System.Classes ==
== START CUT ==
function TStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
begin
{ Default implementation of 64 bit seek is to deflect to existing 32 bit seek.
  Descendents that override 64 bit seek must not call this default implementation. }
  if (Offset < Low(Longint)) or (Offset > High(Longint)) then
    raise ERangeError.CreateRes(@SRangeError);
  Result := Seek(Longint(Offset), Ord(Origin));
end;
== END CUT==
http://stackoverflow.com/questions/3882212/tstream-position-compared-to-tstream-seek

Comments

  1. Because of Longint(Offset). Longint is a signed 32bit Integer -> just like Integer.

    ReplyDelete
  2. Yes, that is true. But there is an overloaded version that is int64. But the code from the sources show it restraining the number to int32 values. That's weird right?

    ReplyDelete
  3. Use TStream.Seek(MyInt64, soBeginning) for 64-bit Seek overload; soFromBeginning calls 32-bit Seek.

    ReplyDelete

Post a Comment