Archive::Lha::Stream::String - Archive::Lha::Stream::String documentation


Archive-Lha documentation Contained in the Archive-Lha distribution.

Index


Code Index:

NAME

Top

Archive::Lha::Stream::String

SYNOPSIS

Top

  my $stream = Archive::Lha::Stream::String->new( string => 'content_of_lzh_file' );

DESCRIPTION

Top

Sometimes you might want to read the content of an .lzh file from DB and the likes. You don't need to prepare a temporary file to store it. Just pass it directly to this stream.

METHODS

Top

new

creates an object, and optionally store a string in the object.

open

takes a hash as an argument and stores the string in the object.

close

does nothing.

eof

sees if the position reached end of the string.

tell

returns the current position.

seek

takes an offset as an argument and sets the position from the string top.

read

takes a length as an argument and returns the chunks of the length (in bytes) from the string.

search_header

searches for the next lzh header.

SEE ALSO

Top

Archive::Lha::Stream

AUTHOR

Top

Kenichi Ishigaki, <ishigaki@cpan.org>

COPYRIGHT AND LICENSE

Top


Archive-Lha documentation Contained in the Archive-Lha distribution.

package Archive::Lha::Stream::String;

use strict;
use warnings;
use Carp;
use bytes;
use base qw( Archive::Lha::Stream::Base );

sub open {
  my ($self, %options) = @_;

  $self->{string} = $options{string} or croak "String is missing";
  $self->{length} = length( $options{string} );
  $self->{pos} = 0;
}

sub close { return }

sub read {
  my ($self, $length) = @_;

  my $str = substr( $self->{string}, $self->{pos}, $length );
  $self->{pos} += $length;
  return $str;
}

1;

__END__