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