S60Extras/group/remove_unwanted_files.pl
changeset 0 6d65d5acee06
equal deleted inserted replaced
-1:000000000000 0:6d65d5acee06
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 #
       
    16 #!/usr/local/bin/perl
       
    17 
       
    18 if ($#ARGV != 1)
       
    19 	{
       
    20 	die "FileRemover\nThis must be called with two parameters:\n	Arg1 : Database of files with their current status\n	Arg2 : Destination batch file to remove the undesired files.\n";
       
    21 	}
       
    22 $database=shift(@ARGV);
       
    23 $resultingList=shift(@ARGV);
       
    24 
       
    25 open(FH,"< $database")|| die "Cannot open file $database for reading\n";
       
    26 open(WFH,"> $resultingList")|| die "Cannot open file $resultingList for writing\n";
       
    27 while ($line=<FH>)
       
    28 	{
       
    29 	$line=uc $line; 	# read all lines in uppercase
       
    30 	chop($line);		# remove EOL char
       
    31 	if (($filename,$status) = $line =~ /([^;\s]+)\s*;\s*([K|R])/) 
       
    32 			# if match found 
       
    33 		{
       
    34 		if ($status eq "R")
       
    35 			{
       
    36 			if (-e $filename)
       
    37 				{
       
    38 				print WFH "call attrib -r $filename\n";
       
    39 				print WFH "call del $filename\n";		
       
    40 				};
       
    41 			if ($filename =~ /([^\\]+)$/)
       
    42 				{
       
    43 				if (-e "\\epoc32\\include\\$1")
       
    44 					{
       
    45 					print WFH "call attrib -r \\epoc32\\include\\$1\n";
       
    46 					print WFH "call del \\epoc32\\include\\$1\n";
       
    47 					}
       
    48 				}
       
    49 			}
       
    50 		}
       
    51 	};
       
    52 close(FH);
       
    53 close(WFH);
       
    54 
       
    55