See SetFilePointer() in Win32API::File (which comes
standard with Win32 Perl).
Note that using Perl file handles with this may present a
problem. You might be able to simply seek before each
call to SetFilePointer():
use Win32API::File qw( SetFilePointer GetOsFHandle );
sub BigTell {
my( $fh )= @_;
seek( $fh, 0, 1 ); # Flush buffers
my $osf= GetOsFHandle( $fh );
my $hi= 0;
my $lo= SetFilePointer( $osf, 0, $hi, 1 );
return pack "NN", $hi, $lo;
}
sub BigSeek {
my( $fh, $pos, $whence )= @_;
my $osf= GetOsFHandle( $fh );
seek($fh,0,1); # Flush buffers
my( $posHi, $posLo )= unpack "NN", $pos;
$posLo= SetFilePointer( $osf, $posLo, $posHi, $whence )
or return;
return pack "NN", $posHi, $posLo;
}
Note that I chose a format for the "big pointer" such that
string comparisons are meaningful.
Unfortunately I don't have time at the moment to test this.
However, if you have problems with it, reply and I'll likely
be able to help.
On the other hand, please reply if this turns out to work
well as it'd make a good addition to Win32API::File. (:
Updated to fix a typo.
-
tye
(but my friends call me "Tye") |