imgtools/buildrom/tools/datadriveimage.pm
author Zheng Shen <zheng.shen@nokia.com>
Tue, 17 Aug 2010 15:31:16 +0800
changeset 626 ac03b93ca9c4
parent 607 378360dbbdba
child 647 53d1ab72f5bc
permissions -rw-r--r--
ROM Tools 12.3.4 + RCOMP 8.4.2
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
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   291
		if( $line =~ /^(file|data)\s*=\s*(\"[^"]+\")\s+(\"[^"]+\")/i || 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   292
				$line =~ /^(file|data)\s*=\s*(\"[^"]+\")\s+(\S+)/i || 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   293
				$line =~ /^(file|data)\s*=\s*(\S+)\s+(\"[^"]+\")/i || 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   294
				$line =~ /^(file|data)\s*=\s*(\S+)\s+(\S+)/i )
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
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   300
			if( $source !~ /(\S+):([^"]+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   301
			{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   302
				$source = get_drive().$2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   303
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   304
			my $var = &copyFilesToFolders( $source,$dest,$dir,$verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   305
			if($var)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   306
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   307
				$line = $keyWord."=".$var."\t".$dest."\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   308
				push(@$nonsisFileArray,$line);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   309
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   310
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   311
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   312
				exit(1)if(!$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   313
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   314
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   315
		elsif($line =~ /^rename\s+(\S+)\s+(\S+)/i)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   316
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   317
			my $oldFile = $dir.$1;	# existing-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   318
			my $newFile = $dir.$2;	# destination-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   319
			print"found rename keyword\nrenaming $oldFile to $newFile\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   320
			if ( rename($oldFile, $newFile) )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   321
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   322
				# push the line on to the stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   323
				push(@$renameArray,$1."\t".$2."\n");
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
				&datadriveimage::reportError("* Warning : can't rename $oldFile to $newFile: $!",$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 =~ /^alias\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 $exFile = $dir.$1;	# existing-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   333
			my $destFile = $dir.$2;	# destination-file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   334
			print"found alias keyword\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   335
			if(!copy($exFile,$destFile))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   336
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   337
				&datadriveimage::reportError("* warning : couldnt create alias of $1 to $2 ",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   338
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   339
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   340
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   341
				# push the line on to the stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   342
				push(@$aliasArray,$1."\t".$2."\n");
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 =~ /^hide\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
			print"found hide keyword\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   348
			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
   349
			if( unlink($dir.$1) )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   350
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   351
				# push the line on to the stack.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   352
				push(@$hideArray,$1);
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
				&datadriveimage::reportError("* Warning : Can't delete $1: $! ",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   357
			}
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
	close(OBEY);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   361
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   362
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   363
# invoke the INTERPRETSIS tool with appropriate parameters.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   364
sub invokeInterpretsis
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   365
{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   366
	my($sisFileArray,$dataDrivePath,$verboseOpt,$zDrivePath,$parafile,$keepgoingOpt,$interpretsisOptList,$outputdir) = @_;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   367
	my $sisfile = ""; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   368
	# 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
   369
	# options are specified.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   370
	my $basicOption = "-d C: ";	# default system drive letter
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   371
	my $command = "interpretsis ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   372
	my $vOption = "-w info" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   373
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   374
	is_existinpath("interpretsis", romutl::DIE_NOT_FOUND);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   375
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   376
	# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   377
	if( $dataDrivePath =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   378
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   379
		$dataDrivePath = '"'.$dataDrivePath.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   380
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   381
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   382
	my $currentdir=cwd;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   383
	$currentdir=~s-\\-\/-go;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   384
	$currentdir.= "\/" unless $currentdir =~ /\/$/;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   385
	$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
   386
	my $drive = "";
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   387
	$drive = $1 if ($currentdir =~ /^(.:)/);
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   388
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   389
	# find out size of the array
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   390
	my $sisarraysize = scalar(@$sisFileArray);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   391
	for( my $i=0; $i<$sisarraysize; $i++ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   392
	{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   393
		my $tempsisfile = pop(@$sisFileArray);
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   394
		if ($tempsisfile =~ /^[\\\/]/)
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   395
		{
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   396
			$tempsisfile = $drive.$tempsisfile;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   397
		}elsif ($tempsisfile !~ /^.:/)
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   398
		{
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   399
			$tempsisfile = $currentdir.$tempsisfile;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   400
		}
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
		if($sisfile ne "")
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   403
		{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   404
			$sisfile = $tempsisfile.",".$sisfile;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   405
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   406
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   407
		{
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   408
			$sisfile = $tempsisfile;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   409
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   410
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   411
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   412
	# check whether the directory exists or not 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   413
	if( -d $zDrivePath )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   414
	{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   415
		# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   416
		if( $zDrivePath =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   417
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   418
			$zDrivePath = '"'.$zDrivePath.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   419
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   420
		$basicOption .= "-z $zDrivePath "; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   421
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   422
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   423
	$basicOption .= "-c $dataDrivePath -s $sisfile $vOption";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   424
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   425
	# if parameter file is specified then invoke the INTERPRETSIS
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   426
	# with the specified parameter file with "-p" option.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   427
	if( defined($parafile) )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   428
	{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   429
		# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   430
		if( $parafile =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   431
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   432
			$parafile = '"'.$parafile.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   433
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   434
		$command .= "-p $parafile "; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   435
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   436
	# else invoke the INTERPRETSIS with default parameter file with "-p" option. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   437
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   438
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   439
		# 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
   440
		$parafile = $outputdir."parameterfile.txt";
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   441
		open( OPTDATA, "> $parafile" )  or die "can't open $parafile";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   442
		print OPTDATA $basicOption."\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   443
		close( OPTDATA );
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   444
		$command .= "-p $parafile ";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   445
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   446
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   447
	if( $interpretsisOptList )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   448
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   449
		# find out size of the array
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   450
		my $arraysize = scalar( @$interpretsisOptList );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   451
		for( my $i = 0; $i < $arraysize; $i++ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   452
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   453
			$command .= $$interpretsisOptList[$i]." ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   454
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   455
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   456
	
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   457
	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
   458
	chdir "$outputdir";
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   459
	
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   460
	print "* Executing $command\n" if ( $verboseOpt );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   461
	system ( $command );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   462
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   463
	if ($? != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   464
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   465
		&datadriveimage::reportError("* ERROR: INTERPRETSIS failed",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   466
	}
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   467
	
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 607
diff changeset
   468
	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
   469
	chdir "$currentdir";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   470
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   471
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   472
# invoke the READIMAGE tool with appropriate parameters.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   473
sub invokeReadImage
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   474
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   475
	my($imageName,$loc,$verboseOpt,$logFile,$keepgoingOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   476
	my $command = "readimage ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   477
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   478
	is_existinpath("readimage", romutl::DIE_NOT_FOUND);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   479
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   480
	# check if log file has been supplied.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   481
	if(defined($logFile))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   482
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   483
		if( $logFile =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   484
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   485
			$logFile = '"'.$logFile.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   486
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   487
		$command .= "-l $logFile ";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   488
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   489
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   490
	# do a check if the path has a white space.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   491
	if( $loc =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   492
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   493
		$loc = '"'.$loc.'"';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   494
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   495
	$command .= "-z ".$loc." ".$imageName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   496
	print "* Executing $command\n" if ($verboseOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   497
	system ($command);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   498
	if ($? != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   499
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   500
		&datadriveimage::reportError("* ERROR: READIMAGE failed to read the image",$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   501
		return 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   502
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   503
	return 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   504
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   505
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   506
# 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
   507
# 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
   508
# 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
   509
# 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
   510
# 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
   511
# 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
   512
# 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
   513
# 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
   514
# with line destination file as the source and destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   515
sub compareArrays
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   516
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   517
	my ( $firstarray,$nonsisArray,$linesource,$linedest,$linekeyword ) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   518
	# count of array element(s).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   519
	my $firstArrayCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   520
	# source file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   521
	my $linesourceFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   522
	# destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   523
	my $linedestFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   524
	# get source file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   525
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   526
	# strip first occurrence of back slash
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   527
	$linesource =~ s/[\/\\]//; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   528
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   529
	# get source file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   530
	if ($linesource =~ /.*[\/\\](\S+)/ ) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   531
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   532
		$linesourceFile = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   533
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   534
	# get destination file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   535
	if ($linedest =~ /.*[\/\\](\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   536
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   537
		$linedestFile = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   538
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   539
	# iterate trough all
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   540
	foreach my $firstarrayEntry (@$firstarray) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   541
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   542
		if( $firstarrayEntry =~ /(\S+)\s+(\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   543
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   544
			my $firstarrayEntrydest = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   545
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   546
			if( $linedest eq $firstarrayEntrydest )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   547
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   548
				# remove the specified element from the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   549
				splice(@$firstarray,$firstArrayCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   550
				# initialize the nonsisFileListCount to zero.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   551
				my $nonsisFileListCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   552
				foreach my $nonsisEntry ( @$nonsisArray )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   553
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   554
					if( $nonsisEntry =~ /^(\S+)=(\S+)\s+(\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   555
					{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   556
						my $nonsisEntryDest = $3;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   557
						# remove double quotes.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   558
						$nonsisEntryDest =~ s/\"//g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   559
						my $nonsisEntryDestFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   560
						if ($nonsisEntryDest =~ /.*[\/\\](\S+)/ ) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   561
						{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   562
							$nonsisEntryDestFile = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   563
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   564
						if( $nonsisEntryDest eq $linesource )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   565
						{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   566
							if($linekeyword eq "rename")
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   567
							{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   568
								# remove the specified element from the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   569
								splice(@$nonsisArray,$nonsisFileListCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   570
								$nonsisEntry =~ s/$nonsisEntryDestFile/$linedestFile/g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   571
								push(@$nonsisArray,$nonsisEntry);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   572
							}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   573
							elsif($linekeyword eq "alias")
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   574
							{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   575
								my $newLine = $nonsisEntry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   576
								$newLine =~ s/$nonsisEntryDestFile/$linedestFile/g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   577
								push(@$nonsisArray,$newLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   578
							}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   579
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   580
					 }
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   581
					$nonsisFileListCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   582
				 }#end of loop foreach my $newLine ( @nonsisArray )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   583
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   584
			$firstArrayCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   585
		}#end of loop foreach my $newLine ( @firstarray) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   586
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   587
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   588
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   589
# Traverse the entire directory and log the folder contents on to a file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   590
sub dumpDatadriveObydata
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   591
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   592
	#assign a temporary name and extension to the new oby file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   593
	my $newobyfile = "temp.$$";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   594
	my ($datadir,$oldobyfile,$size,$nonsisFileArray,$renameArray,$aliasArray,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   595
		$hideArray,$sisobyArray,$datadriveArray,$keepgoingOpt,$verboseOpt) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   596
	# get the working directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   597
	my $curWorkingDir = getcwd;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   598
	# traverse the updated data drive directory structure.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   599
	&TraverseDir($datadir,"",$sisobyArray,$datadir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   600
	# change the directrory to the Working directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   601
	chdir($curWorkingDir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   602
	# copy non-sis file(s) on to prototype data drive folder.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   603
	copyNonSisFiles($datadir,$oldobyfile,$nonsisFileArray,$renameArray,$aliasArray,$hideArray,$verboseOpt,$keepgoingOpt);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   604
	#open the oby file in read-only mode. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   605
	open (OLDDATA, "< $oldobyfile") or die("* Can't open $oldobyfile\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   606
	# Truncate and open the new oby file for writing..
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   607
	open(NEWDATA, "> $newobyfile")  or die "can't open $newobyfile";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   608
	while  (my $line =<OLDDATA>)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   609
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   610
		if( $line =~ /^hide\s+(\S+)/i)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   611
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   612
			my $lineToSearch = $1; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   613
			my $hideListCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   614
			foreach my $newLine ( @$hideArray ) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   615
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   616
				if( $newLine eq $lineToSearch )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   617
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   618
					splice(@$hideArray,$hideListCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   619
					my $nonsisFileListCount = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   620
					foreach my $newLine ( @$nonsisFileArray )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   621
					{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   622
						if( $newLine =~ /^(\S+)=(\S+)\s+(\S+)/ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   623
						{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   624
							my $newLineKeyword = $1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   625
							my $newLinesource = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   626
							my $newLinedest = $3;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   627
							$newLinedest =~ s/\"//g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   628
							$newLinedest = "\/".$newLinedest;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   629
							if( $newLinedest eq $lineToSearch )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   630
							{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   631
								# remove the specified element from the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   632
								splice(@$nonsisFileArray,$nonsisFileListCount,1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   633
							}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   634
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   635
						# increment the non sis file list count.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   636
						$nonsisFileListCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   637
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   638
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   639
				# increment the  hide file list count.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   640
				$hideListCount++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   641
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   642
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   643
		elsif( $line =~ /^rename\s+(\S+)\s+(\S+)/i) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   644
		{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   645
			my $linesource = $1 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   646
			my $linedest = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   647
			my $linekeyword = "rename";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   648
			&compareArrays($renameArray,$nonsisFileArray,$linesource,$linedest,$linekeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   649
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   650
		elsif( $line =~ /^alias\s+(\S+)\s+(\S+)/i )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   651
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   652
			my $linesource = $1 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   653
			my $linedest = $2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   654
			my $linekeyword = "alias";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   655
			&compareArrays($aliasArray,$nonsisFileArray,$linesource,$linedest,$linekeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   656
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   657
		elsif(	$line =~ /^(file|data)\s*=\s*/i || $line =~ /^\s*(zdriveimagename|sisfile)\s*=\s*/i )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   658
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   659
			# skip to next line. 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   660
			next;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   661
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   662
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   663
		{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   664
			# push it on to the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   665
			unshift(@$datadriveArray,$line); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   666
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   667
		next;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   668
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   669
	# close the old oby files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   670
	close(OLDDATA)or die "can't close $oldobyfile";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   671
	#write the array contents on to the file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   672
	print"* Updating $oldobyfile - final OBY file\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   673
	&writeDataToFile( $datadriveArray );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   674
	&writeDataToFile( $sisobyArray );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   675
	&writeDataToFile( $nonsisFileArray );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   676
	# close the new oby file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   677
	close(NEWDATA)or die "can't close $newobyfile";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   678
	#rename the file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   679
	rename( $newobyfile, $oldobyfile )or die "can't rename $newobyfile to $oldobyfile: $!";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   680
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   681
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   682
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   683
# Traverse the entire given directory 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   684
# push all the folder contents on to an array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   685
sub  TraverseDir
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   686
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   687
	my($dir,$folderList,$sisFileContent,$rootdir) = @_;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   688
	#check the specified directory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   689
	chdir($dir) || die "Cannot chdir to $dir\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   690
	local(*DIR);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   691
	opendir(DIR, ".");#open current directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   692
	my $sourcedir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   693
	my $destdir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   694
	while (my $entry=readdir(DIR)) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   695
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   696
		#skip, parent directory and current directory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   697
		next if ($entry eq "." || $entry eq "..");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   698
		#check if it is a file 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   699
		if( -f $entry )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   700
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   701
			my $sourcedir = $rootdir."\/".$folderList.$entry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   702
			my $destdir	= "$folderList".$entry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   703
			my $sisSource;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   704
			my $sisdestination;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   705
			if(&checkRegCtlFiles($entry))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   706
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   707
				# check for any whitespace
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   708
				if($sourcedir =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   709
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   710
					# if yes, then append double quotes
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   711
					$sisSource = "data="."\"".$sourcedir."\"";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   712
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   713
				else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   714
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   715
					# else dont append any double quotes for destination
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   716
					$sisSource = "data=".$sourcedir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   717
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   718
				# push the line on to the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   719
				push(@$sisFileContent,$sisSource."\t".'"'.$destdir.'"');
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   720
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   721
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   722
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   723
				# check for any white space
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   724
				if($sourcedir =~ m/ /)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   725
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   726
					# if yes, then append double quotes
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   727
					$sisSource = "file="."\"".$sourcedir."\"";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   728
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   729
				else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   730
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   731
					# else dont append any double quotes for destination
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   732
					$sisSource = "file=".$sourcedir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   733
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   734
				# push the line on to the array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   735
				push(@$sisFileContent,$sisSource."\t".'"'.$destdir.'"');
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   736
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   737
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   738
		#else it's a directory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   739
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   740
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   741
			&TraverseDir($entry,$folderList.$entry."\/",$sisFileContent,$rootdir);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   742
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   743
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   744
	closedir(DIR);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   745
	chdir("..");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   746
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   747
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   748
# write the data in to oby file by accessing appropriate array.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   749
sub writeDataToFile
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   750
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   751
	my ($array) = @_; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   752
	#get the array size.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   753
	my $arraySize = scalar(@$array);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   754
	for(my $i=0; $i<$arraySize ; $i++ )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   755
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   756
		#pop out the element to the respective obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   757
		my $line=pop(@$array);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   758
		if (&is_windows){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   759
			$line =~ s-\/-\\-g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   760
		}else{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   761
			$line =~ s-\\-\/-g;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   762
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   763
		print NEWDATA $line."\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   764
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   765
}