Commit | Line | Data |
8add82fc |
1 | # |
2 | |
3 | package IO::Seekable; |
4 | |
5 | =head1 NAME |
6 | |
7 | IO::Seekable - supply seek based methods for I/O objects |
8 | |
84dc3c4d |
9 | =head1 SYNOPSIS |
10 | |
27d4819a |
11 | use IO::Seekable; |
12 | package IO::Something; |
13 | @ISA = qw(IO::Seekable); |
84dc3c4d |
14 | |
8add82fc |
15 | =head1 DESCRIPTION |
16 | |
de592821 |
17 | C<IO::Seekable> does not have a constructor of its own as it is intended to |
8add82fc |
18 | be inherited by other C<IO::Handle> based objects. It provides methods |
19 | which allow seeking of the file descriptors. |
20 | |
21 | If the C functions fgetpos() and fsetpos() are available, then |
cf7fe8a2 |
22 | C<$io-E<lt>getpos> returns an opaque value that represents the |
23 | current position of the IO::File, and C<$io-E<gt>setpos(POS)> uses |
8add82fc |
24 | that value to return to a previously visited position. |
25 | |
26 | See L<perlfunc> for complete descriptions of each of the following |
27 | supported C<IO::Seekable> methods, which are just front ends for the |
28 | corresponding built-in functions: |
a6006777 |
29 | |
cf7fe8a2 |
30 | $io->seek( POS, WHENCE ) |
31 | $io->sysseek( POS, WHENCE ) |
32 | $io->tell |
8add82fc |
33 | |
34 | =head1 SEE ALSO |
35 | |
36 | L<perlfunc>, |
37 | L<perlop/"I/O Operators">, |
27d4819a |
38 | L<IO::Handle> |
39 | L<IO::File> |
8add82fc |
40 | |
41 | =head1 HISTORY |
42 | |
cf7fe8a2 |
43 | Derived from FileHandle.pm by Graham Barr E<lt>gbarr@pobox.comE<gt> |
8add82fc |
44 | |
8add82fc |
45 | =cut |
46 | |
17f410f9 |
47 | require 5.005_64; |
8add82fc |
48 | use Carp; |
7a4c00b4 |
49 | use strict; |
17f410f9 |
50 | our($VERSION, @EXPORT, @ISA); |
d5b0d4de |
51 | use IO::Handle (); |
52 | # XXX we can't get these from IO::Handle or we'll get prototype |
53 | # mismatch warnings on C<use POSIX; use IO::File;> :-( |
54 | use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); |
8add82fc |
55 | require Exporter; |
56 | |
57 | @EXPORT = qw(SEEK_SET SEEK_CUR SEEK_END); |
58 | @ISA = qw(Exporter); |
59 | |
cf7fe8a2 |
60 | $VERSION = "1.08"; |
8add82fc |
61 | |
8add82fc |
62 | sub seek { |
cf7fe8a2 |
63 | @_ == 3 or croak 'usage: $io->seek(POS, WHENCE)'; |
8add82fc |
64 | seek($_[0], $_[1], $_[2]); |
65 | } |
66 | |
cf7fe8a2 |
67 | sub sysseek { |
68 | @_ == 3 or croak 'usage: $io->sysseek(POS, WHENCE)'; |
69 | sysseek($_[0], $_[1], $_[2]); |
70 | } |
71 | |
8add82fc |
72 | sub tell { |
cf7fe8a2 |
73 | @_ == 1 or croak 'usage: $io->tell()'; |
8add82fc |
74 | tell($_[0]); |
75 | } |
76 | |
77 | 1; |