226 lines
4.8 KiB
HTML
226 lines
4.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Archive::Zip::MemberRead</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Archive::Zip::MemberRead</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-02-27<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Archive::Zip::MemberRead - A wrapper that lets you read Zip archive members as if they were files.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use Archive::Zip;
|
|
use Archive::Zip::MemberRead;
|
|
$zip = Archive::Zip->new("file.zip");
|
|
$fh = Archive::Zip::MemberRead->new($zip, "subdir/abc.txt");
|
|
while (defined($line = $fh->getline()))
|
|
{
|
|
print $fh->input_line_number . "#: $line\n";
|
|
}
|
|
|
|
$read = $fh->read($buffer, 32*1024);
|
|
print "Read $read bytes as :$buffer:\n";
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
The Archive::Zip::MemberRead module lets you read Zip archive member data
|
|
just like you read data from files.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>Archive::Zip::Member::readFileHandle()</B><DD>
|
|
|
|
|
|
You can get a <TT>"Archive::Zip::MemberRead"</TT> from an archive member by
|
|
calling <TT>"readFileHandle()"</TT>:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $member = $zip->memberNamed('abc/def.c');
|
|
my $fh = $member->readFileHandle();
|
|
while (defined($line = $fh->getline()))
|
|
{
|
|
# ...
|
|
}
|
|
$fh->close();
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="2">Archive::Zip::MemberRead->new($zip, $fileName)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="3">Archive::Zip::MemberRead->new($zip, $member)<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="4">Archive::Zip::MemberRead->new($member)<DD>
|
|
|
|
|
|
|
|
Construct a new Archive::Zip::MemberRead on the specified member.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $fh = Archive::Zip::MemberRead->new($zip, 'fred.c')
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="5">setLineEnd(expr)<DD>
|
|
|
|
|
|
Set the line end character to use. This is set to \n by default
|
|
except on Windows systems where it is set to \r\n. You will
|
|
only need to set this on systems which are not Windows or Unix
|
|
based and require a line end different from \n.
|
|
This is a class method so call as <TT>"Archive::Zip::MemberRead"</TT>-><TT>"setLineEnd($nl)"</TT>
|
|
<DT id="6"><B>rewind()</B><DD>
|
|
|
|
|
|
Rewinds an <TT>"Archive::Zip::MemberRead"</TT> so that you can read from it again
|
|
starting at the beginning.
|
|
<DT id="7">input_record_separator(expr)<DD>
|
|
|
|
|
|
If the argument is given, input_record_separator for this
|
|
instance is set to it. The current setting (which may be
|
|
the global $/) is always returned.
|
|
<DT id="8"><B>input_line_number()</B><DD>
|
|
|
|
|
|
Returns the current line number, but only if you're using <TT>"getline()"</TT>.
|
|
Using <TT>"read()"</TT> will not update the line number.
|
|
<DT id="9"><B>close()</B><DD>
|
|
|
|
|
|
Closes the given file handle.
|
|
<DT id="10">buffer_size([ $size ])<DD>
|
|
|
|
|
|
|
|
|
|
Gets or sets the buffer size used for reads.
|
|
Default is the chunk size used by Archive::Zip.
|
|
<DT id="11"><B>getline()</B><DD>
|
|
|
|
|
|
Returns the next line from the currently open member.
|
|
Makes sense only for text files.
|
|
A read error is considered fatal enough to die.
|
|
Returns undef on eof. All subsequent calls would return undef,
|
|
unless a <B>rewind()</B> is called.
|
|
Note: The line returned has the input_record_separator (default: newline) removed.
|
|
<DT id="12">getline( { preserve_line_ending => 1 } )<DD>
|
|
|
|
|
|
Returns the next line including the line ending.
|
|
<DT id="13">read($buffer, $num_bytes_to_read)<DD>
|
|
|
|
|
|
|
|
|
|
Simulates a normal <TT>"read()"</TT> system call.
|
|
Returns the no. of bytes read. <TT>"undef"</TT> on error, 0 on eof, <I>e.g.</I>:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$fh = Archive::Zip::MemberRead->new($zip, "sreeji/secrets.bin");
|
|
while (1)
|
|
{
|
|
$read = $fh->read($buffer, 1024);
|
|
die "FATAL ERROR reading my secrets !\n" if (!defined($read));
|
|
last if (!$read);
|
|
# Do processing.
|
|
....
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Sreeji K. Das <<A HREF="mailto:sreeji_k@yahoo.com">sreeji_k@yahoo.com</A>>
|
|
<P>
|
|
|
|
See Archive::Zip by Ned Konz without which this module does not make
|
|
any sense!
|
|
<P>
|
|
|
|
Minor mods by Ned Konz.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright 2002 Sreeji K. Das.
|
|
<P>
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
the same terms as Perl itself.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="14"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="15"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="16"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="17"><A HREF="#lbAE">METHODS</A><DD>
|
|
<DT id="18"><A HREF="#lbAF">AUTHOR</A><DD>
|
|
<DT id="19"><A HREF="#lbAG">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:35 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|