1Archive::Zip::MemberReaUds(e3r)Contributed Perl DocumentAartcihoinve::Zip::MemberRead(3)
2
3
4
6 Archive::Zip::MemberRead - A wrapper that lets you read Zip archive
7 members as if they were files.
8
10 use Archive::Zip;
11 use Archive::Zip::MemberRead;
12 $zip = Archive::Zip->new("file.zip");
13 $fh = Archive::Zip::MemberRead->new($zip, "subdir/abc.txt");
14 while (defined($line = $fh->getline()))
15 {
16 print $fh->input_line_number . "#: $line\n";
17 }
18
19 $read = $fh->read($buffer, 32*1024);
20 print "Read $read bytes as :$buffer:\n";
21
23 The Archive::Zip::MemberRead module lets you read Zip archive member
24 data just like you read data from files.
25
27 Archive::Zip::Member::readFileHandle()
28 You can get a "Archive::Zip::MemberRead" from an archive member by
29 calling "readFileHandle()":
30
31 my $member = $zip->memberNamed('abc/def.c');
32 my $fh = $member->readFileHandle();
33 while (defined($line = $fh->getline()))
34 {
35 # ...
36 }
37 $fh->close();
38
39 Archive::Zip::MemberRead->new($zip, $fileName)
40 Archive::Zip::MemberRead->new($zip, $member)
41 Archive::Zip::MemberRead->new($member)
42 Construct a new Archive::Zip::MemberRead on the specified member.
43
44 my $fh = Archive::Zip::MemberRead->new($zip, 'fred.c')
45
46 setLineEnd(expr)
47 Set the line end character to use. This is set to \n by default
48 except on Windows systems where it is set to \r\n. You will only
49 need to set this on systems which are not Windows or Unix based and
50 require a line end diffrent from \n. This is a class method so
51 call as "Archive::Zip::MemberRead"->"setLineEnd($nl)"
52
53 rewind()
54 Rewinds an "Archive::Zip::MemberRead" so that you can read from it
55 again starting at the beginning.
56
57 input_record_separator(expr)
58 If the argumnet is given, input_record_separator for this instance
59 is set to it. The current setting (which may be the global $/) is
60 always returned.
61
62 input_line_number()
63 Returns the current line number, but only if you're using
64 "getline()". Using "read()" will not update the line number.
65
66 close()
67 Closes the given file handle.
68
69 buffer_size([ $size ])
70 Gets or sets the buffer size used for reads. Default is the chunk
71 size used by Archive::Zip.
72
73 getline()
74 Returns the next line from the currently open member. Makes sense
75 only for text files. A read error is considered fatal enough to
76 die. Returns undef on eof. All subsequent calls would return
77 undef, unless a rewind() is called. Note: The line returned has
78 the input_record_separator (default: newline) removed.
79
80 read($buffer, $num_bytes_to_read)
81 Simulates a normal "read()" system call. Returns the no. of bytes
82 read. "undef" on error, 0 on eof, e.g.:
83
84 $fh = Archive::Zip::MemberRead->new($zip, "sreeji/secrets.bin");
85 while (1)
86 {
87 $read = $fh->read($buffer, 1024);
88 die "FATAL ERROR reading my secrets !\n" if (!defined($read));
89 last if (!$read);
90 # Do processing.
91 ....
92 }
93
95 Sreeji K. Das, <sreeji_k@yahoo.com> See Archive::Zip by Ned Konz
96 without which this module does not make any sense!
97
98 Minor mods by Ned Konz.
99
101 Copyright 2002 Sreeji K. Das.
102
103 This program is free software; you can redistribute it and/or modify it
104 under the same terms as Perl itself.
105
106
107
108perl v5.12.0 2009-06-30 Archive::Zip::MemberRead(3)