in reply to seek function always returns true

UNIX at least, it's explicitly allowed to seek past the end of a file (so that you can create files with holes in them). You'll probably only get an error if you try to read at that point.

Replies are listed 'Best First'.
Re^2: seek function always returns true
by johngg (Canon) on Jun 19, 2007 at 22:31 UTC
    I had heard of files with holes but didn't realise the implicatons for seek. Looks like you do get the read error on Solaris.

    $ ls -l xxxx -rw-r--r-- 1 johngg users 639 Jun 19 23:26 xxxx $ perl -le ' > open $in, q{<}, q{xxxx} or die $!; > seek $in, 1000, 0 == tell $in or die q{bad seek}; > print tell $in; > 10 == read $in, $buf, 10 or die q{bad read}; > print tell $in; > print $buf;' 1000 bad read at -e line 5. $

    Cheers,

    JohnGG

Re^2: seek function always returns true
by cdarke (Prior) on Jun 20, 2007 at 07:40 UTC
    Same on Windows (SetFilePointerEx API).