P is for Practical | |
PerlMonks |
Re: Re: testing for a zip fileby adrianh (Chancellor) |
on Aug 29, 2003 at 21:10 UTC ( [id://287834]=note: print w/replies, xml ) | Need Help?? |
You can check the first 2 bytes of the file. If they are PK, then you have a .zip file. Or, to be slightly more accurate, if they are not PK you know that you don't have a .zip file :-) There is nothing to stop a non-zip file starting with PK. If you want to be sure use Archive::Zip to attempt to extract the file or check the file's CRCs.
In Section
Seekers of Perl Wisdom
|
|