Martinw has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to zip a folder (and the files within it) but not the subdirectories within it.
I have used the addTree function which works fine but also zips the subdirectories. I've also attempted the addDirectory and addFile functions neither of which I can get to work correctly. When i run my script with addDirectory i dont get any errors or warnings and the zip file is created but it is empty.
for example:Works perfectly butmy $zip = Archive::Zip->new(); $zip->addTree( 'C:\Users\Martin\Documents\Scripts\testfolder\\' ); unless ( $zip->writeToFileNamed($BACKUPNAME) == AZ_OK ) { die 'write error'; }
ormy $zip = Archive::Zip->new(); $zip->addFile( 'C:\Users\Martin\Documents\Scripts\testfolder\file1.txt +' ); unless ( $zip->writeToFileNamed($BACKUPNAME) == AZ_OK ) { die 'write error'; }
both create zip files but they are empty. Any ideas would be much appreciated. Thanksmy $zip = Archive::Zip->new(); $zip->addDirectory( 'C:\Users\Martin\Documents\Scripts\testfolder\\' ) +; unless ( $zip->writeToFileNamed($BACKUPNAME) == AZ_OK ) { die 'write error'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with Archive::zip
by ahmad (Hermit) on May 18, 2010 at 14:23 UTC | |
by Martinw (Initiate) on May 18, 2010 at 15:50 UTC |