Add ARM files
[dh-make-perl] / dev / arm / libarchive-zip-perl / libarchive-zip-perl-1.18 / debian / libarchive-zip-perl / usr / share / doc / libarchive-zip-perl / examples / updateTree.pl
1 # Shows how to update a Zip in place using a temp file.
2 #
3 # usage:
4 #       perl [-m] examples/updateTree.pl zipfile.zip dirname
5 #
6 # -m means to mirror
7 #
8 # $Id: updateTree.pl,v 1.2 2003/11/27 17:03:51 ned Exp $
9 #
10 use Archive::Zip qw(:ERROR_CODES);
11
12 my $mirror = 0;
13 if ( $ARGV[0] eq '-m' ) { shift; $mirror = 1; }
14
15 my $zipName = shift || die 'must provide a zip name';
16 my $dirName = shift || die 'must provide a directory name';
17
18 # Read the zip
19 my $zip = Archive::Zip->new();
20
21 if ( -f $zipName )
22 {
23         die "can't read $zipName\n" unless $zip->read($zipName) == AZ_OK;
24
25         # Update the zip
26         $zip->updateTree($dirName, undef, undef, $mirror);
27
28         # Now the zip is updated. Write it back via a temp file.
29         exit( $zip->overwrite() );
30 }
31 else    # new zip
32 {
33         $zip->addTree($dirName);
34         exit( $zip->writeToFileNamed($zipName) );
35 }