bldsystemtools/commonbldutils/GenResult/ZipDiamondsXml.pm
branchRCL_3
changeset 24 d90029decf65
parent 20 a9d4531388d0
child 33 54aa4a06a075
child 34 5e522efbae7b
equal deleted inserted replaced
20:a9d4531388d0 24:d90029decf65
     1 # Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Script that will zip the XMLs generated
       
    15 #
       
    16 package ZipDiamondsXml;
       
    17 use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
       
    18 use strict;
       
    19 
       
    20 my $ZipFile = "DiamondsXmls.zip";
       
    21 my $tempZipFile = "DiamondsXmls.zip.new";
       
    22 &main("");
       
    23 sub main
       
    24 {
       
    25   my $FileToAdd = shift;
       
    26   $FileToAdd =~ /([^\\\/]*?)$/;
       
    27   my $FileName = $1;
       
    28   my $zip = Archive::Zip->new();
       
    29   if (-e $ZipFile)
       
    30   {
       
    31     die 'Zip read error' if $zip->read($ZipFile) != AZ_OK;
       
    32   }
       
    33   my $member = $zip->addFile($FileToAdd,$FileName);
       
    34   die 'Zip write error' if $zip->writeToFileNamed($tempZipFile) != AZ_OK;
       
    35   unlink($ZipFile);
       
    36   rename($tempZipFile,$ZipFile);
       
    37 }