imgtools/buildrom/tools/datadriveimage.pm
author jascui
Wed, 17 Nov 2010 13:39:15 +0800
changeset 687 da9e6195bd8d
parent 647 53d1ab72f5bc
permissions -rw-r--r--
Updating release text and product version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     1
#
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     2
# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     3
# All rights reserved.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     4
# This component and the accompanying materials are made available
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     6
# which accompanies this distribution, and is available
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     8
#
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     9
# Initial Contributors:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    10
# Nokia Corporation - initial contribution.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    11
#
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    12
# Contributors:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    13
#
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    14
# Description: 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    15
# This package contains fuctions specific to data drive image generation
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    16
#
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    17
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    18
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    19
package datadriveimage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    20
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    21
require Exporter;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    22
@ISA=qw(Exporter);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    23
@EXPORT=qw(
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    24
			createDirectory 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    25
			deleteDirectory 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    26
			checkInArray 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    27
			setPath 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    28
			locateStubsisfiles 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    29
			copyFilesToFolders 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    30
			checkForSisFile 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    31
			copyNonSisFiles
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    32
			invokeInterpretsis
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    33
			invokeReadImage
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    34
			compareArrays
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    35
			dumpDatadriveObydata
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    36
			TraverseDir
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    37
			writeDataToFile
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    38
			generate_datadriveheader
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    39
			checkForWhiteSpace
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    40
			reportError
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    41
);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    42
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    43
use strict;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    44
use File::Path;		# Module to provide functions to remove or create directories in a convenient way.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    45
use File::Copy;		# Module to provide functions to copy file(s) from source to destination.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    46
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    47
use Cwd;			# Module to provide functions for determining the pathname of the current working directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    48
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    49
use romutl;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    50
use romosvariant;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    51
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    52
# This fuction is used primiarly to check for whitespace in the location for "zdrive" / "datadrive" folder creation,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    53
# specified by the user, if yes then it returns one, else zero
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    54
sub checkForWhiteSpace
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    55
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    56
	my ($dirLoc,$dirName) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    57
	if( $dirLoc =~ m/ / )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    58
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    59
		print "* Warning: $dirLoc contains whitespace, hence $dirName will be created in default location \n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    60
		return 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    61
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    62
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    63
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    64
		return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    65
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    66
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    67
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    68
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    69
# This function reports the appropriate meassage supplied to it
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    70
# and does a exit if and only if keepgoing option is disabled.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    71
sub reportError
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    72
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    73
	my( $message,$keepgoingOpt ) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    74
	# print the specified meassage.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    75
	print STDERR "$message \n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    76
	# bail out, if keepgoing option is not set.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    77
	exit(1) if (!$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    78
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    79
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    80
# generate header for final datadrive oby file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    81
sub generate_datadriveheader
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    82
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    83
	my ($idx,$datadriveimage) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    84
	my $header;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    85
	$header =  "dataimagename=$$datadriveimage[$idx]{name}.img\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    86
	$header .= "dataimagefilesystem=$$datadriveimage[$idx]{fstype}\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    87
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    88
	# check whether the size of the image has been mentioned
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    89
	if(defined($$datadriveimage[$idx]{size}))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    90
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    91
		$header .= "dataimagesize=$$datadriveimage[$idx]{size}\n\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    92
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    93
	return $header;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    94
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    95
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    96
# Create the specified directory by making use of mkpath function 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    97
# from File::Path module.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    98
sub createDirectory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    99
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   100
	my($dir) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   101
	if( !-d $dir )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   102
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   103
		mkpath($dir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   104
		if (! -e $dir) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   105
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   106
			print ("ERROR: Couldn't create $dir\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   107
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   108
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   109
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   110
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   111
# check if the given file is a reg file or ctl file or a txt file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   112
# if it is any of these files then return true else false.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   113
# This check is need since these three files or not valid not valid e32 file 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   114
# and hence needs to be placed as an data file inside the image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   115
sub checkRegCtlFiles
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   116
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   117
	my ($fileName) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   118
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   119
	# check whether the file has "reg","ctl" or "txt" extension.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   120
	if( $fileName =~/\.(reg|ctl|txt)$/i )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   121
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   122
		return 1;		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   123
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   124
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   125
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   126
		return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   127
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   128
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   129
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   130
# delete the given directory by making use of rmtree function 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   131
# from File::Path module.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   132
sub deleteDirectory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   133
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   134
	my($dir,$verboseOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   135
	# check whether the directory exists.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   136
	if( -d $dir )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   137
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   138
		print("found $dir directory \n") if($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   139
		if(rmtree($dir))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   140
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   141
			print("$dir directory deleted \n") if($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   142
			return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   143
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   144
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   145
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   146
			print("$dir directory could'nt be deleted \n") if($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   147
			return 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   148
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   149
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   150
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   151
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   152
# check for processed data drive image index.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   153
# if there is a match return one else return zero.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   154
# this check is done in order to ensure data drive image index is not repeated.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   155
sub checkInArray
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   156
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   157
	my($array, $value) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   158
	foreach my $aLine(@$array)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   159
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   160
		if( $aLine eq $value )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   161
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   162
			return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   163
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   164
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   165
	return 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   166
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   167
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   168
# set the path for the given directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   169
sub setPath
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   170
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   171
	my($dirName) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   172
	# get the working directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   173
	my $curWorkingDir = getcwd;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   174
	# substitute slash with double backward slash.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   175
	$curWorkingDir =~ s/\\/\//g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   176
 	#if $curWorkingDir already has trailing '\', don't include it again 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   177
 	if( $curWorkingDir =~ /\/$/)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   178
 	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   179
 		return $curWorkingDir.$dirName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   180
 	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   181
 	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   182
 	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   183
 		return $curWorkingDir."\/".$dirName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   184
 	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   185
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   186
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   187
# create directory and copy respective file on to that directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   188
# is there is a problem while copying files from source to destination
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   189
# then bail out if and only if keep going option is disabled.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   190
sub copyFilesToFolders
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   191
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   192
	my ($source,$dest,$dir,$verboseOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   193
	$source =~ s/\"//g; # remove double quotes from the string. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   194
	my $destFileName = "";	# name of the destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   195
	$dest =~ s/\"//g;	# remove double quotes from the string. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   196
	my $destDirectory = $dest;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   197
	# strip the last substring to get destination file 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   198
	if ($dest=~/.*[\/\\](\S+)/) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   199
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   200
		$destFileName = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   201
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   202
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   203
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   204
		$destFileName = $dest;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   205
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   206
	#get the destination directory along with full path
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   207
	#when "[" and "]" appear in the file name we need add "\" before "[" or "]"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   208
	#like this: [filename].exe translate to \[filename\].exe 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   209
	if($destFileName =~ /\[|\]/)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   210
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   211
		my $tempFileName = $destFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   212
		$tempFileName =~ s/(\[|\])/\\$1/g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   213
		$destDirectory =~ s/$tempFileName//;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   214
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   215
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   216
	{	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   217
		$destDirectory =~ s/$destFileName//;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   218
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   219
	my $destfile = $dir."\/".$dest;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   220
	my $createdir = $dir."\/".$destDirectory ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   221
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   222
	# create the specified directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   223
	&createDirectory($createdir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   224
	if (!copy($source,$destfile))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   225
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   226
		warn "warning : $source file could not found \n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   227
		return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   228
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   229
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   230
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   231
		print "$source copied to $destfile\n" if($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   232
		return "\"".$destfile."\"";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   233
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   234
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   235
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   236
# Make a check for sisfile keyword by reading the specified iby/oby file,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   237
# if sisfile keyword is found then push the respective image on to the respective array 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   238
# and return true.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   239
sub checkForSisFile 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   240
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   241
	my($obyfile,$sisFileArray,$sisFilePrestent) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   242
	# open the oby file in read only mode. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   243
	open (DATA, "< $obyfile") or die("* Can't open $obyfile\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   244
	while  (my $line =<DATA>)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   245
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   246
		if($line =~ /^\s*sisfile\s*=\s*(\S+)/i )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   247
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   248
			# found a sis file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   249
			$$sisFilePrestent = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   250
			# push sis file on to stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   251
			push(@$sisFileArray,$1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   252
			next;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   253
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   254
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   255
	close(DATA);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   256
	return $$sisFilePrestent;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   257
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   258
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   259
# Make a check for zdriveimagename keyword by reading the specified iby/oby file,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   260
# if zdriveimagename keyword is found then push the respective image on to the respective array 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   261
# and return true.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   262
sub checkForZDriveImageKeyword 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   263
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   264
	#$ZDriveImageFilePresent
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   265
	my($obyfile,$ZDriveImageKeywordArray,$ImageFilePresent) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   266
	# open the oby file in read only mode. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   267
	open (DATA, "< $obyfile") or die("* Can't open $obyfile\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   268
	while  (my $line =<DATA>)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   269
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   270
		if($line =~ /^\s*zdriveimagename\s*=\s*(\S+)/i )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   271
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   272
			# found a Z Drive Image file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   273
			$$ImageFilePresent = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   274
			# push sis file on to stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   275
			push(@$ZDriveImageKeywordArray,$1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   276
			next;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   277
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   278
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   279
	close(DATA);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   280
	return $$ImageFilePresent;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   281
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   282
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   283
# copy all non-sis file(s) on to prototype data drive folder 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   284
# which are mentioned under input data drive iby/oby file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   285
sub copyNonSisFiles
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   286
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   287
	my($dir,$obyfile,$nonsisFileArray,$renameArray,$aliasArray,$hideArray,$verboseOpt,$keepgoingOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   288
	open (OBEY ,$obyfile) or die($obyfile."\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   289
	while(my $line =<OBEY>) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   290
	{
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   291
		if( $line =~ /^(file|data|dircopy)\s*=\s*(\"[^"]+\")\s+(\"[^"]+\")/i || 
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   292
				$line =~ /^(file|data|dircopy)\s*=\s*(\"[^"]+\")\s+(\S+)/i || 
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   293
				$line =~ /^(file|data|dircopy)\s*=\s*(\S+)\s+(\"[^"]+\")/i || 
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   294
				$line =~ /^(file|data|dircopy)\s*=\s*(\S+)\s+(\S+)/i )
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   295
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   296
			my $keyWord=$1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   297
			my $source=$2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   298
			my $dest=$3;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   299
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   300
			my $currentdir=cwd;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   301
			$currentdir=~s-\\-\/-go;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   302
			$currentdir.= "\/" unless $currentdir =~ /\/$/;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   303
			$currentdir =~ s-\/-\\-g if (&is_windows);
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   304
			my $drive = "";
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   305
			$drive = $1 if ($currentdir =~ /^(.:)/);
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   306
			$source =~ s/\"//g;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   307
			if ($source =~ /^[\\\/]/)
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   308
			{
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   309
				$source = $drive.$source;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   310
			}elsif ($source !~ /^.:/)
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   311
			{
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   312
				$source = $currentdir.$source;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   313
			}
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   314
			$source = "\"".$source."\"";
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   315
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   316
			my $var = $source;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   317
			if ($keyWord ne "dircopy"){
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   318
				$var = &copyFilesToFolders( $source,$dest,$dir,$verboseOpt);
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   319
			}
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   320
			if($var)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   321
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   322
				$line = $keyWord."=".$var."\t".$dest."\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   323
				push(@$nonsisFileArray,$line);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   324
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   325
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   326
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   327
				exit(1)if(!$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   328
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   329
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   330
		elsif($line =~ /^rename\s+(\S+)\s+(\S+)/i)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   331
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   332
			my $oldFile = $dir.$1;	# existing-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   333
			my $newFile = $dir.$2;	# destination-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   334
			print"found rename keyword\nrenaming $oldFile to $newFile\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   335
			if ( rename($oldFile, $newFile) )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   336
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   337
				# push the line on to the stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   338
				push(@$renameArray,$1."\t".$2."\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   339
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   340
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   341
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   342
				&datadriveimage::reportError("* Warning : can't rename $oldFile to $newFile: $!",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   343
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   344
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   345
		elsif($line =~ /^alias\s+(\S+)\s+(\S+)/i)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   346
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   347
			my $exFile = $dir.$1;	# existing-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   348
			my $destFile = $dir.$2;	# destination-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   349
			print"found alias keyword\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   350
			if(!copy($exFile,$destFile))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   351
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   352
				&datadriveimage::reportError("* warning : couldnt create alias of $1 to $2 ",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   353
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   354
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   355
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   356
				# push the line on to the stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   357
				push(@$aliasArray,$1."\t".$2."\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   358
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   359
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   360
		elsif($line =~ /^hide\s+(\S+)/i)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   361
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   362
			print"found hide keyword\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   363
			print "$1 is marked as hidden, hence will not be part of the image\n" if($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   364
			if( unlink($dir.$1) )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   365
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   366
				# push the line on to the stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   367
				push(@$hideArray,$1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   368
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   369
			else 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   370
			{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   371
				&datadriveimage::reportError("* Warning : Can't delete $1: $! ",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   372
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   373
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   374
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   375
	close(OBEY);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   376
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   377
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   378
# invoke the INTERPRETSIS tool with appropriate parameters.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   379
sub invokeInterpretsis
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   380
{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   381
	my($sisFileArray,$dataDrivePath,$verboseOpt,$zDrivePath,$parafile,$keepgoingOpt,$interpretsisOptList,$outputdir) = @_;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   382
	my $sisfile = ""; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   383
	# default system drive letter is specified since interpretsis doesnt allow overloading of options unless default 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   384
	# options are specified.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   385
	my $basicOption = "-d C: ";	# default system drive letter
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   386
	my $command = "interpretsis ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   387
	my $vOption = "-w info" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   388
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   389
	# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   390
	if( $dataDrivePath =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   391
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   392
		$dataDrivePath = '"'.$dataDrivePath.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   393
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   394
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   395
	my $currentdir=cwd;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   396
	$currentdir=~s-\\-\/-go;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   397
	$currentdir.= "\/" unless $currentdir =~ /\/$/;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   398
	$currentdir =~ s-\/-\\-g if (&is_windows);
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   399
	my $drive = "";
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   400
	$drive = $1 if ($currentdir =~ /^(.:)/);
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   401
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   402
	# find out size of the array
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   403
	my $sisarraysize = scalar(@$sisFileArray);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   404
	for( my $i=0; $i<$sisarraysize; $i++ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   405
	{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   406
		my $tempsisfile = pop(@$sisFileArray);
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   407
		if ($tempsisfile =~ /^[\\\/]/)
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   408
		{
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   409
			$tempsisfile = $drive.$tempsisfile;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   410
		}elsif ($tempsisfile !~ /^.:/)
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   411
		{
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   412
			$tempsisfile = $currentdir.$tempsisfile;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   413
		}
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   414
		
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   415
		if($sisfile ne "")
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   416
		{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   417
			$sisfile = $tempsisfile.",".$sisfile;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   418
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   419
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   420
		{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   421
			$sisfile = $tempsisfile;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   422
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   423
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   424
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   425
	# check whether the directory exists or not 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   426
	if( -d $zDrivePath )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   427
	{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   428
		# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   429
		if( $zDrivePath =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   430
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   431
			$zDrivePath = '"'.$zDrivePath.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   432
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   433
		$basicOption .= "-z $zDrivePath "; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   434
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   435
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   436
	$basicOption .= "-c $dataDrivePath -s $sisfile $vOption";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   437
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   438
	# if parameter file is specified then invoke the INTERPRETSIS
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   439
	# with the specified parameter file with "-p" option.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   440
	if( defined($parafile) )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   441
	{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   442
		# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   443
		if( $parafile =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   444
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   445
			$parafile = '"'.$parafile.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   446
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   447
		$command .= "-p $parafile "; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   448
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   449
	# else invoke the INTERPRETSIS with default parameter file with "-p" option. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   450
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   451
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   452
		# Truncate and open the parameter file for writing..
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   453
		$parafile = $outputdir."parameterfile.txt";
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   454
		open( OPTDATA, "> $parafile" )  or die "can't open $parafile";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   455
		print OPTDATA $basicOption."\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   456
		close( OPTDATA );
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   457
		$command .= "-p $parafile ";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   458
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   459
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   460
	if( $interpretsisOptList )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   461
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   462
		# find out size of the array
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   463
		my $arraysize = scalar( @$interpretsisOptList );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   464
		for( my $i = 0; $i < $arraysize; $i++ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   465
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   466
			$command .= $$interpretsisOptList[$i]." ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   467
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   468
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   469
	
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   470
	print "* Changing to $outputdir\n" if ( $verboseOpt );
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   471
	chdir "$outputdir";
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   472
	
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   473
	my $epocroot = &get_epocroot;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   474
	if ($epocroot !~ /^(.:)/)
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   475
	{
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   476
	  $ENV{EPOCROOT} = $drive.$epocroot;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   477
	}
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   478
	print "* Executing $command\n" if ( $verboseOpt );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   479
	system ( $command );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   480
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   481
	if ($? != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   482
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   483
		&datadriveimage::reportError("* ERROR: INTERPRETSIS failed",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   484
	}
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   485
	
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   486
	print "* Changing back to $currentdir\n" if ( $verboseOpt );
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   487
	chdir "$currentdir";
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   488
	$ENV{EPOCROOT} = $epocroot;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   489
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   490
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   491
# invoke the READIMAGE tool with appropriate parameters.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   492
sub invokeReadImage
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   493
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   494
	my($imageName,$loc,$verboseOpt,$logFile,$keepgoingOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   495
	my $command = "readimage ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   496
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   497
	is_existinpath("readimage", romutl::DIE_NOT_FOUND);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   498
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   499
	# check if log file has been supplied.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   500
	if(defined($logFile))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   501
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   502
		if( $logFile =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   503
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   504
			$logFile = '"'.$logFile.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   505
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   506
		$command .= "-l $logFile ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   507
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   508
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   509
	# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   510
	if( $loc =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   511
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   512
		$loc = '"'.$loc.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   513
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   514
	$command .= "-z ".$loc." ".$imageName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   515
	print "* Executing $command\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   516
	system ($command);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   517
	if ($? != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   518
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   519
		&datadriveimage::reportError("* ERROR: READIMAGE failed to read the image",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   520
		return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   521
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   522
	return 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   523
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   524
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   525
# Each line from the OBY file is read and if any of the line contains "rename"/ "alias" keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   526
# then that corresponding line source and line destination is obtained and is passed to this function as one of the parameters.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   527
# This fuction compares given array with non-sis file(s) array, when an given line destination matches with the destination of an
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   528
# element in the rename array/alias array(array holding list of file(s) that are renamed / made alias) then,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   529
# that respective element is removed from the rename array and a further check is made to see whether the given
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   530
# line source matches with the destination of an element in the rename array/alias array.If a match is found then
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   531
# a keyword check is done,if the keyword is "rename" then corresponding element's source and destination file is replaced
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   532
# with given line destination file and if the keyword is "alias" then a new element will be added to non sis file array
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   533
# with line destination file as the source and destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   534
sub compareArrays
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   535
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   536
	my ( $firstarray,$nonsisArray,$linesource,$linedest,$linekeyword ) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   537
	# count of array element(s).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   538
	my $firstArrayCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   539
	# source file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   540
	my $linesourceFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   541
	# destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   542
	my $linedestFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   543
	# get source file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   544
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   545
	# strip first occurrence of back slash
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   546
	$linesource =~ s/[\/\\]//; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   547
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   548
	# get source file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   549
	if ($linesource =~ /.*[\/\\](\S+)/ ) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   550
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   551
		$linesourceFile = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   552
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   553
	# get destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   554
	if ($linedest =~ /.*[\/\\](\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   555
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   556
		$linedestFile = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   557
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   558
	# iterate trough all
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   559
	foreach my $firstarrayEntry (@$firstarray) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   560
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   561
		if( $firstarrayEntry =~ /(\S+)\s+(\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   562
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   563
			my $firstarrayEntrydest = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   564
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   565
			if( $linedest eq $firstarrayEntrydest )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   566
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   567
				# remove the specified element from the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   568
				splice(@$firstarray,$firstArrayCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   569
				# initialize the nonsisFileListCount to zero.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   570
				my $nonsisFileListCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   571
				foreach my $nonsisEntry ( @$nonsisArray )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   572
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   573
					if( $nonsisEntry =~ /^(\S+)=(\S+)\s+(\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   574
					{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   575
						my $nonsisEntryDest = $3;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   576
						# remove double quotes.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   577
						$nonsisEntryDest =~ s/\"//g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   578
						my $nonsisEntryDestFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   579
						if ($nonsisEntryDest =~ /.*[\/\\](\S+)/ ) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   580
						{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   581
							$nonsisEntryDestFile = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   582
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   583
						if( $nonsisEntryDest eq $linesource )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   584
						{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   585
							if($linekeyword eq "rename")
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   586
							{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   587
								# remove the specified element from the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   588
								splice(@$nonsisArray,$nonsisFileListCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   589
								$nonsisEntry =~ s/$nonsisEntryDestFile/$linedestFile/g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   590
								push(@$nonsisArray,$nonsisEntry);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   591
							}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   592
							elsif($linekeyword eq "alias")
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   593
							{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   594
								my $newLine = $nonsisEntry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   595
								$newLine =~ s/$nonsisEntryDestFile/$linedestFile/g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   596
								push(@$nonsisArray,$newLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   597
							}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   598
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   599
					 }
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   600
					$nonsisFileListCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   601
				 }#end of loop foreach my $newLine ( @nonsisArray )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   602
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   603
			$firstArrayCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   604
		}#end of loop foreach my $newLine ( @firstarray) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   605
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   606
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   607
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   608
# Traverse the entire directory and log the folder contents on to a file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   609
sub dumpDatadriveObydata
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   610
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   611
	#assign a temporary name and extension to the new oby file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   612
	my $newobyfile = "temp.$$";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   613
	my ($datadir,$oldobyfile,$size,$nonsisFileArray,$renameArray,$aliasArray,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   614
		$hideArray,$sisobyArray,$datadriveArray,$keepgoingOpt,$verboseOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   615
	# get the working directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   616
	my $curWorkingDir = getcwd;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   617
	# traverse the updated data drive directory structure.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   618
	&TraverseDir($datadir,"",$sisobyArray,$datadir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   619
	# change the directrory to the Working directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   620
	chdir($curWorkingDir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   621
	# copy non-sis file(s) on to prototype data drive folder.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   622
	copyNonSisFiles($datadir,$oldobyfile,$nonsisFileArray,$renameArray,$aliasArray,$hideArray,$verboseOpt,$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   623
	#open the oby file in read-only mode. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   624
	open (OLDDATA, "< $oldobyfile") or die("* Can't open $oldobyfile\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   625
	# Truncate and open the new oby file for writing..
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   626
	open(NEWDATA, "> $newobyfile")  or die "can't open $newobyfile";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   627
	while  (my $line =<OLDDATA>)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   628
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   629
		if( $line =~ /^hide\s+(\S+)/i)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   630
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   631
			my $lineToSearch = $1; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   632
			my $hideListCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   633
			foreach my $newLine ( @$hideArray ) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   634
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   635
				if( $newLine eq $lineToSearch )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   636
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   637
					splice(@$hideArray,$hideListCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   638
					my $nonsisFileListCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   639
					foreach my $newLine ( @$nonsisFileArray )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   640
					{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   641
						if( $newLine =~ /^(\S+)=(\S+)\s+(\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   642
						{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   643
							my $newLineKeyword = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   644
							my $newLinesource = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   645
							my $newLinedest = $3;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   646
							$newLinedest =~ s/\"//g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   647
							$newLinedest = "\/".$newLinedest;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   648
							if( $newLinedest eq $lineToSearch )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   649
							{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   650
								# remove the specified element from the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   651
								splice(@$nonsisFileArray,$nonsisFileListCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   652
							}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   653
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   654
						# increment the non sis file list count.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   655
						$nonsisFileListCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   656
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   657
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   658
				# increment the  hide file list count.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   659
				$hideListCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   660
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   661
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   662
		elsif( $line =~ /^rename\s+(\S+)\s+(\S+)/i) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   663
		{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   664
			my $linesource = $1 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   665
			my $linedest = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   666
			my $linekeyword = "rename";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   667
			&compareArrays($renameArray,$nonsisFileArray,$linesource,$linedest,$linekeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   668
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   669
		elsif( $line =~ /^alias\s+(\S+)\s+(\S+)/i )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   670
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   671
			my $linesource = $1 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   672
			my $linedest = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   673
			my $linekeyword = "alias";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   674
			&compareArrays($aliasArray,$nonsisFileArray,$linesource,$linedest,$linekeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   675
		}
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   676
		elsif(	$line =~ /^(file|data|dircopy)\s*=\s*/i || $line =~ /^\s*(zdriveimagename|sisfile)\s*=\s*/i )
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   677
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   678
			# skip to next line. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   679
			next;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   680
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   681
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   682
		{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   683
			# push it on to the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   684
			unshift(@$datadriveArray,$line); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   685
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   686
		next;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   687
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   688
	# close the old oby files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   689
	close(OLDDATA)or die "can't close $oldobyfile";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   690
	#write the array contents on to the file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   691
	print"* Updating $oldobyfile - final OBY file\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   692
	&writeDataToFile( $datadriveArray );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   693
	&writeDataToFile( $sisobyArray );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   694
	&writeDataToFile( $nonsisFileArray );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   695
	# close the new oby file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   696
	close(NEWDATA)or die "can't close $newobyfile";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   697
	#rename the file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   698
	rename( $newobyfile, $oldobyfile )or die "can't rename $newobyfile to $oldobyfile: $!";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   699
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   700
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   701
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   702
# Traverse the entire given directory 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   703
# push all the folder contents on to an array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   704
sub  TraverseDir
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   705
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   706
	my($dir,$folderList,$sisFileContent,$rootdir) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   707
	#check the specified directory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   708
	chdir($dir) || die "Cannot chdir to $dir\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   709
	local(*DIR);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   710
	opendir(DIR, ".");#open current directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   711
	my $sourcedir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   712
	my $destdir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   713
	while (my $entry=readdir(DIR)) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   714
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   715
		#skip, parent directory and current directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   716
		next if ($entry eq "." || $entry eq "..");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   717
		#check if it is a file 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   718
		if( -f $entry )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   719
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   720
			my $sourcedir = $rootdir."\/".$folderList.$entry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   721
			my $destdir	= "$folderList".$entry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   722
			my $sisSource;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   723
			my $sisdestination;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   724
			if(&checkRegCtlFiles($entry))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   725
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   726
				# check for any whitespace
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   727
				if($sourcedir =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   728
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   729
					# if yes, then append double quotes
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   730
					$sisSource = "data="."\"".$sourcedir."\"";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   731
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   732
				else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   733
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   734
					# else dont append any double quotes for destination
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   735
					$sisSource = "data=".$sourcedir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   736
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   737
				# push the line on to the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   738
				push(@$sisFileContent,$sisSource."\t".'"'.$destdir.'"');
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   739
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   740
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   741
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   742
				# check for any white space
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   743
				if($sourcedir =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   744
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   745
					# if yes, then append double quotes
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   746
					$sisSource = "file="."\"".$sourcedir."\"";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   747
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   748
				else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   749
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   750
					# else dont append any double quotes for destination
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   751
					$sisSource = "file=".$sourcedir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   752
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   753
				# push the line on to the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   754
				push(@$sisFileContent,$sisSource."\t".'"'.$destdir.'"');
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   755
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   756
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   757
		#else it's a directory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   758
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   759
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   760
			&TraverseDir($entry,$folderList.$entry."\/",$sisFileContent,$rootdir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   761
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   762
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   763
	closedir(DIR);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   764
	chdir("..");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   765
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   766
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   767
# write the data in to oby file by accessing appropriate array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   768
sub writeDataToFile
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   769
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   770
	my ($array) = @_; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   771
	#get the array size.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   772
	my $arraySize = scalar(@$array);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   773
	for(my $i=0; $i<$arraySize ; $i++ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   774
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   775
		#pop out the element to the respective obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   776
		my $line=pop(@$array);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   777
		if (&is_windows){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   778
			$line =~ s-\/-\\-g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   779
		}else{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   780
			$line =~ s-\\-\/-g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   781
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   782
		print NEWDATA $line."\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   783
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   784
}