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 | |
17 | C<IO::Seekable> does not have a constuctor of its own as is intended to |
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 |
22 | C<IO::File::getpos> returns an opaque value that represents the |
23 | current position of the IO::File, and C<IO::File::setpos> uses |
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 | |
8add82fc |
30 | clearerr |
31 | seek |
32 | tell |
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 | |
27d4819a |
43 | Derived from FileHandle.pm by Graham Barr E<lt>bodg@tiuk.ti.comE<gt> |
8add82fc |
44 | |
8add82fc |
45 | =cut |
46 | |
47 | require 5.000; |
48 | use Carp; |
7a4c00b4 |
49 | use strict; |
8add82fc |
50 | use vars qw($VERSION @EXPORT @ISA); |
51 | use IO::Handle qw(SEEK_SET SEEK_CUR SEEK_END); |
52 | require Exporter; |
53 | |
54 | @EXPORT = qw(SEEK_SET SEEK_CUR SEEK_END); |
55 | @ISA = qw(Exporter); |
56 | |
7a4c00b4 |
57 | $VERSION = "1.06"; |
8add82fc |
58 | |
59 | sub clearerr { |
60 | @_ == 1 or croak 'usage: $fh->clearerr()'; |
61 | seek($_[0], 0, SEEK_CUR); |
62 | } |
63 | |
64 | sub seek { |
65 | @_ == 3 or croak 'usage: $fh->seek(POS, WHENCE)'; |
66 | seek($_[0], $_[1], $_[2]); |
67 | } |
68 | |
69 | sub tell { |
70 | @_ == 1 or croak 'usage: $fh->tell()'; |
71 | tell($_[0]); |
72 | } |
73 | |
74 | 1; |