Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2007
    Posts
    3

    Unanswered: 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

  2. #2
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    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).

  3. #3
    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.

  4. #4
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    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.

  5. #5
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •