alanhaggai's Journal
http://use.perl.org/~alanhaggai/journal/
alanhaggai's use Perl Journalen-ususe Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.2012-01-25T02:44:52+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00alanhaggai's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~alanhaggai/journal/
Back to coding
http://use.perl.org/~alanhaggai/journal/39093?from=rss
<p>I am glad to be back on track after some time. Started to write tests first. It is interesting.</p><p>I am rewriting support for named arguments in Archive-Zip (which I had added earlier), so that this time, there will be automated tests for them. Tests were manual earlier, of which I got tired soon due to one-thing-breaking-the-other, and the chain-of-reactions!</p>alanhaggai2009-06-08T03:59:43+00:00journalUpdate on General Purpose Bit Flag bug
http://use.perl.org/~alanhaggai/journal/37735?from=rss
<p><code>bitFlag()</code> sub was modified with the addition of the following conditions:</p><p>Desired Compression Level | Speed / Compression<br>1, 2 | Fast<br>3, 4, 5, 6, 7 | Normal<br>8, 9 | Maximum</p><p>Thus, <code>Archive::Zip</code> will set the bits exactly the same way that the GNU/Linux <code>zip</code> utility does.</p>alanhaggai2008-10-25T12:38:20+00:00journalArchive::Zip does not set General Purpose Bit Flag
http://use.perl.org/~alanhaggai/journal/37727?from=rss
<p>After analysing few<nobr> <wbr></nobr>.zip files with the<nobr> <wbr></nobr>.Zip file parser (<a href="http://code.google.com/p/zipparser/">http://code.google.com/p/zipparser/</a>), I was able to find out that <code>Archive::Zip</code> does not (for some reason) set the bits of General Purpose Bit Flag.</p><p>This means that<nobr> <wbr></nobr>.zip file members' compression levels will not be stored in the archive.</p><p>Let us reproduce it by creating two<nobr> <wbr></nobr>.zip files named <code>hello-zip.zip</code> (created with the GNU/Linux <code>zip</code> utility) and <code>hello-az.zip</code> created with <code>Archive::Zip</code> for comparison. Both the files contain:</p><p>
<code>Filename: hello<br>
Content:<br>
Hello world.<br>
Hello world.<br>
Hello world<br>
<br> <br>
</code> </p><p>Let us compress:</p><p>
<code>[alanhaggai@archer zip]$ zip -9 hello-zip.zip hello<br>
adding: hello (deflated 54%)<br>
<br> <br>
#!/usr/bin/perl -w<br>
<br> <br>
use strict;<br>
use Archive::Zip qw(<nobr> <wbr></nobr>:ERROR_CODES<nobr> <wbr></nobr>:CONSTANTS );<br>
<br> <br>
my $zip = Archive::Zip->new;<br>
my $member = $zip->addFile('hello');<br>
$member->desiredCompressionLevel(9);<br>
$zip->writeToFileNamed('hello-az.zip');<br>
</code>
</p><p>Now, let us compare relevant parts of the<nobr> <wbr></nobr>.Zip files (several of the zip_parser.conf elements were commented out for brevity):
</p><p>
<code>[alanhaggai@archer zip]$<nobr> <wbr></nobr>./zip_parser hello-zip.zip
END CENTRAL DIRECTORY RECORD<br>
--------------------------------------------------<br>
<br>
<br>
<br>
LOCAL FILE HEADER<br>
--------------------------------------------------<br>
<br> <br>
Compressed_Size -> <br>
18<br>
Compression_Method -> <br>
The file is Deflated<br>
Filename -> <br>
hello<br>
General_Purpose_Bit_Flag -> <br>
Maximum (-exx/-ex) compression option was used<br>
Uncompressed_Size -> <br>
39<br>
<br>
<br>
CENTRAL DIRECTORY RECORD<br>
--------------------------------------------------<br>
<br> <br>
Compressed_Size -> <br>
18<br>
Compression_Method -> <br>
The file is Deflated<br>
Filename -> <br>
hello<br>
General_Purpose_Bit_Flag -> <br>
Maximum (-exx/-ex) compression option was used<br>
Uncompressed_Size -> <br>
39<br>
<br> <br>
[alanhaggai@archer zip]$<nobr> <wbr></nobr>./zip_parser hello-az.zip<br>
END CENTRAL DIRECTORY RECORD<br>
--------------------------------------------------<br>
<br>
<br>
<br>
LOCAL FILE HEADER<br>
--------------------------------------------------<br>
<br> <br>
Compressed_Size -> <br>
18<br>
Compression_Method -> <br>
The file is Deflated<br>
Filename -> <br>
hello<br>
General_Purpose_Bit_Flag -> <br>
Normal (-en) compression option was used<br>
Uncompressed_Size -> <br>
39<br>
<br>
<br>
CENTRAL DIRECTORY RECORD<br>
--------------------------------------------------<br>
<br> <br>
Compressed_Size -> <br>
18<br>
Compression_Method -> <br>
The file is Deflated<br>
Filename -> <br>
hello<br>
General_Purpose_Bit_Flag -> <br>
Normal (-en) compression option was used<br>
Uncompressed_Size -> <br>
39<br>
</code>
</p><p>Both the files were compressed at level 9 (maximum compression). However, <code>Archive::Zip</code> did not set the `General Purpose Bit Flag', and so, suggest: `Normal (-en) compression option was used'.</p><p>In the case of <code>hello-zip.zip</code> produced by the <code>zip</code> utility, the flag's bits were set and suggest: `Maximum (-exx/-ex) compression option was used'.</p>alanhaggai2008-10-24T18:15:55+00:00journalZip Parser
http://use.perl.org/~alanhaggai/journal/37691?from=rss
I have written a<nobr> <wbr></nobr>.Zip file parser. This parser can be (hopefully) used to identify buggy areas of Archive::Zip and possibly other<nobr> <wbr></nobr>.Zip file writers. Currently, it lacks the capability to parse Zip64 and encrypted<nobr> <wbr></nobr>.Zip files. I wish to add support for those soon.alanhaggai2008-10-18T06:08:41+00:00journalStudy of Data::ParseBinary
http://use.perl.org/~alanhaggai/journal/37637?from=rss
I have been studying <a href="http://search.cpan.org/~semuelf/Data-ParseBinary-0.07c/lib/Data/ParseBinary.pm">Data::ParseBinary</a> for a while. I sincerely hope to be able to build a dissector for<nobr> <wbr></nobr>.zip file format.alanhaggai2008-10-10T06:49:45+00:00journalWork resumed
http://use.perl.org/~alanhaggai/journal/37245?from=rss
I have resumed work on the Archive::Zip grant.alanhaggai2008-08-22T01:40:34+00:00journalWork on Archive::Zip Stopped for Two Weeks
http://use.perl.org/~alanhaggai/journal/37157?from=rss
<p>My work on Archive::Zip has been stopped for two weeks as my right-eye contracted a viral infection. I am applying eye-drops and ointments. However, it is difficult to concentrate in work as I have to take frequent naps. Also, the right eye has got blurred in vision due to the disease. The blurriness interferes a lot. So, I thought of stopping the work for two weeks, which is the period within which I hope the eye will cure ( the doctor said so ).</p><p>I will post as soon as I get back to work.</p>alanhaggai2008-08-11T17:15:50+00:00journal.zip file format
http://use.perl.org/~alanhaggai/journal/36860?from=rss
<p>My study of the<nobr> <wbr></nobr>.zip file format:</p><p><b>Magic bytes</b> </p><blockquote><div><p>Magic numbers are common in programs across many operating systems. Magic numbers implement strongly typed data and are a form of in-band signaling to the controlling program that reads the data type(s) at program run-time. Many files have such constants that identify the contained data. Detecting such constants in files is a simple and effective way of distinguishing between many file formats and can yield further run-time information.</p></div></blockquote><p>That is Wikipedia's definition of magic bytes / numbers.<nobr> <wbr></nobr>.zip magic bytes are:<br>0x50 0x45 at offset 0x00.<br>0x50 = P,<br>and 0x45 = K in ASCII.</p><p>PK stands for <a href="http://en.wikipedia.org/wiki/Phil_Katz">Phil Katz</a>, the creator of the<nobr> <wbr></nobr>.zip file format.</p><p><b>Meta Data</b></p><ul> <li>Optional archive comment</li><li>Optional comment per entry</li><li>All kinds of system-specific data ( like file attributes ) can be added per file using so called extra fields</li></ul><p><b>Limitations</b></p><ul> <li>Internal offset values are 32-bits large, so only files upto 4 GB can be stored</li><li>No support for extended character sets in file names</li></ul>alanhaggai2008-07-06T17:57:43+00:00journalGrant proposal accepted!
http://use.perl.org/~alanhaggai/journal/36566?from=rss
<p>My proposal `<strong>Fixing Bugs in the Archive::Zip Perl Module</strong>' has been accepted by The Perl Foundation. Shlomi Fish ( <a href="http://www.shlomifish.org/">http://www.shlomifish.org</a> ) helped me with the proposal, supported me and also encouraged me.</p><p>Thank you very much Shlomi.<nobr> <wbr></nobr>:-)</p><p>
<small>I am having examinations at college now. I will start working as soon as the examinations are over.</small></p>alanhaggai2008-06-02T19:06:18+00:00journalFixing Bugs in the Archive::Zip Perl Module
http://use.perl.org/~alanhaggai/journal/36211?from=rss
<p> <b>Abstract:</b> Perl programs often need to manipulate<nobr> <wbr></nobr>.zip files. Archive::Zip (<a href="http://search.cpan.org/dist/Archive-Zip/">http://search.cpan.org/dist/Archive-Zip/</a>) is a Perl module that allows a Perl program to manage Zip archive files without calling an external utility.</p><p>The Archive::Zip module, however, has some bugs which prevent it from generating fully-portable<nobr> <wbr></nobr>.zip files, that are handled correctly by all<nobr> <wbr></nobr>.zip file readers and manipulators. The project's main aim is to address the outstanding bug reports (<a href="http://rt.cpan.org/Public/Dist/Display.html?Name=Archive-Zip">http://rt.cpan.org/Public/Dist/Display.html?Name=Archive-Zip</a>), by using pyconstruct (<a href="http://pyconstruct.wikispaces.com/">http://pyconstruct.wikispaces.com/</a>), which is a flexible framework for defining dissectors for binary formats in a declarative way.</p><p>I have to start working on the project soon. I, most probably, will be having the time to work from the start of May 2008. I am very thrilled to work on it and be part of the Perl community.</p><p>Hope the project goes well. I am also applying for `The Perl Foundation Grants'.</p>alanhaggai2008-04-22T05:05:41+00:00cpanFirst write up
http://use.perl.org/~alanhaggai/journal/36070?from=rss
This is my first write up at `use Perl'. Hope to write more soon.alanhaggai2008-04-06T05:00:43+00:00journal