I am using
Archive::Zip and
Archive::Zip::Tree for the first time and have come across a problem, and can't find any mention of it in the docs.
I have put the contents of directory
C:\Windows\Desktop\carl\zip\mysql into an archive.
The contents consist of 1 file
'setup.exe', and 1 subfolder
'sub-folder' containing 1 file
'setup.bmp'.
I put all of this in a root folder named
'backup' within the archive.
However, after I run my script and check the contents of the archive, there is also a folder called
'C:' in the archive, with an empty directory structure within it.
Below is a representation of the archive directory structure, my expected structure, and then the script I used to create it.
Note: I have used 2 different zip utilities to check the contents of the archive and verify that the empty dir structure is really there.
Contents of test.zip
C:
->Windows
->Desktop
->Carl
->zip
->mysql
backup
->sub-folder
->setup.bmp
->setup.exe
What I expect it to look like:
backup
->sub-folder
->setup.bmp
->setup.exe
The script:
#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip qw/ :ERROR_CODES :CONSTANTS/;
use Archive::Zip::Tree;
my $dir = 'C:\Windows\Desktop\carl\zip\mysql';
my $file = 'C:\Windows\Desktop\carl\test.zip';
my $name = 'backup';
my $zip = Archive::Zip->new();
$zip->addTree( $dir, $name ) == AZ_OK
or die("could not add tree");
$zip->writeToFileNamed( $file ) == AZ_OK
or die("could not write file");
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.