Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Perl and Zip files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-07, 17:43
inspectorblooper inspectorblooper is offline
Registered User
 
Join Date: Sep 2007
Posts: 3
Perl and Zip files

I've locate the following logit to retrieve data on the contents of a zip file:

Open ZIP and MPG file to get size.
use Archive::Zip;
my $zip = Archive::Zip->new($ARGV[0]);
foreach my $member ($zip->members())
{
printf("%8d %8d %s %s\n",
$member->uncompressedSize(),
$member->compressedSize(),
scalar(localtime($member->lastModFileDateTime())),
$member->fileName()
);
}


QUESTOION:
I need to obtain the date, size, and any other meta data about the zip file and not just its contents. Can someone provide feedback on a module that will enable me to complete this task?

Thanks,
inspector
Reply With Quote
  #2 (permalink)  
Old 09-30-07, 18:16
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Fort Polk, LA
Posts: 500
Quote:
Originally Posted by inspectorblooper
QUESTOION:
I need to obtain the date, size, and any other meta data about the zip file and not just its contents. Can someone provide feedback on a module that will enable me to complete this task?

Thanks,
inspector

You don't need a module to do this. The standard -x operators will tell you everything about files (zip or otherwise), as well as the stat or lstat functions (also listed on that page).
Reply With Quote
  #3 (permalink)  
Old 10-11-07, 17:22
inspectorblooper inspectorblooper is offline
Registered User
 
Join Date: Sep 2007
Posts: 3
Perl and zip files

I am familiar with the stat function, which I use for some file size checks; however, due to the number of systems involved in creating the zip and mpg files, I was under the impression that I should be able to read the zip file header information that will tell me hard facts about the file I am reading.

I've learned that the following logic only supplies specifics about the files contained in the zip file:

use Archive::Zip;
my $zip = Archive::Zip->new($file_key);
foreach my $member ($zip->members())
{
printf("FILENAME=%s \n", $member->fileName());
printf("UNCOMPRESSEDSIZE=%8d \n", $member->uncompressedSize());
printf("COMPRESSEDSIZE=%8d \n", $member->compressedSize());
printf("LASTMODFILEDATETIME=%s \n", scalar(localtime($member->lastModFileDateTime())));
printf("DATAOFFSET=%s \n", $member->dataOffset);
printf("DISKNUMBERSTART=%s \n", $member->diskNumberStart);
printf("EXTERNALFILENAME=%s \n", $member->externalFileName);
printf("INTERNALFILEATTRIBUTES=%s \n", $member->internalFileAttributes);
printf("VERSIONNEEDEDTOEXTRACT=%s \n", $member->versionNeededToExtract);
printf("EXTERNALFILEATTRIBUTES=%s \n", $member->externalFileAttributes);
printf("DESIREDCOMPRESSIONLEVEL=%s \n", $member->desiredCompressionLevel);
printf("FH=%s \n", $member->fh);
printf("CDEXTRAFIELD=%s \n", $member->cdExtraField);
printf("COMPRESSIONMETHOD=%s \n", $member->compressionMethod);
printf("DESIREDCOMPRESSIONMETHOD=%s \n", $member->desiredCompressionMethod);
printf("LOCALEXTRAFIELD=%s \n", $member->localExtraField);
printf("FILECOMMENT=%s \n", $member->fileComment);
printf("LOCALHEADERRELATIVEOFFSET=%s \n", $member->localHeaderRelativeOffset);
printf("VERSIONMADEBY=%s \n", $member->versionMadeBy);
printf("BITFLAG=%s \n", $member->bitFlag);
printf("FILEATTRIBUTEFORMAT=%s \n", $member->fileAttributeFormat);
printf("CRC32=%s \n", $member->crc32);
}


Is there any way to retrieve the zip or mpg file header information within Perl? Or is the stat/lstat function my only option to retrieving specific data about the file size, date, etc?

Thanks for the feedback.
Reply With Quote
  #4 (permalink)  
Old 10-12-07, 23:08
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Fort Polk, LA
Posts: 500
Here's the problem: all the information in a zip file relates to files within the zip file. But don't take my word for it, read the zip file specs.

So, no, Perl can't look in the zip file to find out who modified it because that info simply isn't there. If you're using some utility to create your Zip files and they store nonstandard information, your best bet would be to find their modified specs and subclass Archive::Zip yourself. But there's no reason to store that information because the OS stores it in the normal file system.

BTW, if stat doesn't get what you need, there are platform specific modules that do. You'd probably find them on search.cpan.org.
Reply With Quote
  #5 (permalink)  
Old 10-14-07, 11:19
inspectorblooper inspectorblooper is offline
Registered User
 
Join Date: Sep 2007
Posts: 3
Perl and Zip files

You've confirmed my findings thus far.

The stat function does supply me with the information and will have to do outside of adding logic to check each file size contained in the zip file prior to and after unzipping the zip file.

Thanks for the feedback.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On