sbsv1/abld/e32util/deletefeaturevariants.pl
changeset 599 fa7a3cc6effd
equal deleted inserted replaced
596:9f25be3da657 599:fa7a3cc6effd
       
     1 # Copyright (c) 2007-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 # delete A.X.aaa for all X (32 chars) when given A.aaa
       
    15 # 
       
    16 #
       
    17 
       
    18 
       
    19 my $source = shift;
       
    20 
       
    21 # delete invariant
       
    22 unlink($source) if (-f $source);
       
    23 
       
    24 # now think about variants
       
    25 
       
    26 use File::Basename;
       
    27 my $srcDir = dirname($source);
       
    28 my $srcRoot = basename($source);
       
    29 my $srcExt = "";
       
    30 
       
    31 if ($srcRoot =~ /^(.+)\.([^\.]+)$/)
       
    32 {
       
    33 	$srcRoot = $1;
       
    34 	$srcExt = $2;
       
    35 }
       
    36 
       
    37 opendir(DIR, $srcDir) or die("ERROR: cannot read directory $srcDir\n");
       
    38 
       
    39 # delete all variants
       
    40 while (my $file = readdir(DIR))
       
    41 {
       
    42 	unlink("$srcDir/$file") if ($file =~ /^$srcRoot\.(\w{32})\.$srcExt$/i);
       
    43 }
       
    44 
       
    45 exit 1 if (!closedir(DIR));
       
    46 exit 0;
       
    47