home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / pc / software / entwickl / win95 / pw32i306.exe / lib / IO / seekable.pm < prev    next >
Text File  |  1996-10-07  |  2KB  |  78 lines

  1. #
  2.  
  3. package IO::Seekable;
  4.  
  5. =head1 NAME
  6.  
  7. IO::Seekable - supply seek based methods for I/O objects
  8.  
  9. =head1 SYNOPSIS
  10.  
  11.     use IO::Seekable;
  12.     package IO::Something;
  13.     @ISA = qw(IO::Seekable);
  14.  
  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:
  29.   
  30.     clearerr
  31.     seek
  32.     tell
  33.  
  34. =head1 SEE ALSO
  35.  
  36. L<perlfunc>, 
  37. L<perlop/"I/O Operators">,
  38. L<IO::Handle>
  39. L<IO::File>
  40.  
  41. =head1 HISTORY
  42.  
  43. Derived from FileHandle.pm by Graham Barr E<lt>bodg@tiuk.ti.comE<gt>
  44.  
  45. =head1 REVISION
  46.  
  47. $Revision: 1.5 $
  48.  
  49. =cut
  50.  
  51. require 5.000;
  52. use Carp;
  53. use vars qw($VERSION @EXPORT @ISA);
  54. use IO::Handle qw(SEEK_SET SEEK_CUR SEEK_END);
  55. require Exporter;
  56.  
  57. @EXPORT = qw(SEEK_SET SEEK_CUR SEEK_END);
  58. @ISA = qw(Exporter);
  59.  
  60. $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
  61.  
  62. sub clearerr {
  63.     @_ == 1 or croak 'usage: $fh->clearerr()';
  64.     seek($_[0], 0, SEEK_CUR);
  65. }
  66.  
  67. sub seek {
  68.     @_ == 3 or croak 'usage: $fh->seek(POS, WHENCE)';
  69.     seek($_[0], $_[1], $_[2]);
  70. }
  71.  
  72. sub tell {
  73.     @_ == 1 or croak 'usage: $fh->tell()';
  74.     tell($_[0]);
  75. }
  76.  
  77. 1;
  78.