diff -r 000000000000 -r 83f4b4db085c bldsystemtools/commonbldutils/FileOps.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bldsystemtools/commonbldutils/FileOps.pl Tue Feb 02 01:39:43 2010 +0200 @@ -0,0 +1,95 @@ +# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Script to do file operations within a directory with the option to exclude sub directories or files +# +# + +use strict; +use FindBin; # for FindBin::Bin +use Getopt::Long; + +use lib $FindBin::Bin; + +use FileOps; + +# Process the commandline +my ($iSourceDir, $iTargetDir, $iAction, @iExcludes) = &ProcessCommandLine(); + +&FileOps::ProcessDir($iSourceDir, $iTargetDir, $iAction, @iExcludes); + +# ProcessCommandLine +# +# Inputs +# +# Outputs +# +# Description +# This function processes the commandline + +sub ProcessCommandLine { + my ($iHelp, $iSourceDir, $iTargetDir, $iAction, @iExclude, @iExcludes); + GetOptions('h' => \$iHelp, 's=s' =>\$iSourceDir, 't:s' =>\$iTargetDir, 'a=s' => \$iAction, 'x:s@' => \@iExclude); + + if (($iHelp) || (!defined $iSourceDir) || (!defined $iAction)) + { + Usage(); + } elsif (! -d $iSourceDir) { + die "$iSourceDir is not a Directory"; + } elsif ((lc($iAction) ne 'copy') && (lc($iAction) ne 'move') && (lc($iAction) ne 'delete') && (lc($iAction) ne 'zip')) { + die "$iAction is not a supported Action"; + } elsif ((lc($iAction) eq 'copy') || (lc($iAction) eq 'move') && (lc($iAction) ne 'delete')) { + if (!defined $iTargetDir) + { + die "$iAction Requires a Target Directory"; + } + if (! -d $iTargetDir) + { + die "$iTargetDir is not a Directory"; + } + } + + # Check all the exclude sub directories or files + foreach my $iSubItem (@iExclude) + { + if ((! -d "$iSourceDir\\$iSubItem") && (! -f "$iSourceDir\\$iSubItem")) + { + print "$iSubItem is not a Directory or File in $iSourceDir - not Excluding\n"; + } else { + push @iExcludes,$iSubItem; + } + } + + return($iSourceDir, $iTargetDir, $iAction, @iExcludes); +} + +# Usage +# +# Output Usage Information. +# + +sub Usage { + print <