| 1 | package KinoSearch1::Store::InStream; | ||
| 2 | use base qw( KinoSearch1::Util::CClass ); | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use KinoSearch1::Util::ToolSet; | ||
| 6 | |||
| 7 | sub close { CORE::close shift->get_fh } | ||
| 8 | |||
| 9 | =for comment | ||
| 10 | Dupe the filehandle and create a new object around the dupe. Seek the dupe | ||
| 11 | to the same spot as the original. | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | sub clone_stream { | ||
| 16 | my $self = shift; | ||
| 17 | open( my $duped_fh, '<&=', $self->get_fh ) | ||
| 18 | or confess("Couldn't dupe filehandle: $!"); | ||
| 19 | my $evil_twin | ||
| 20 | = __PACKAGE__->new( $duped_fh, $self->get_offset, $self->length, ); | ||
| 21 | $evil_twin->seek( $self->tell ); | ||
| 22 | return $evil_twin; | ||
| 23 | } | ||
| 24 | |||
| 25 | 1; | ||
| 26 | |||
| 27 | __END__ |