imgtools/romtools/rofsbuild/rofsbuild.cpp
author kelvzhu
Tue, 27 Jul 2010 13:00:43 +0800
changeset 621 96fee2635b19
parent 617 3a747a240983
child 626 ac03b93ca9c4
permissions -rw-r--r--
Fixed Bug 2413 for evalid
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) 2007-2010 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
*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    16
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    17
#include <string.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    18
#include <stdlib.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    19
#include <f32file.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    20
#include "e32image.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    21
#include "h_utl.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    22
#include "h_ver.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    23
#include "r_obey.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    24
#include "r_driveimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    25
#include "r_driveutl.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    26
#include "r_coreimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    27
#include "parameterfileprocessor.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    28
#include "r_smrimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    29
//cache headers
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    30
#include "cache/cacheexception.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    31
#include "cache/cacheentry.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    32
#include "cache/cache.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    33
#include "cache/cachegenerator.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    34
#include "cache/cachevalidator.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    35
#include "cache/cacheablelist.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    36
#include "cache/cachemanager.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    37
#include <malloc.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    38
 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    39
#ifndef WIN32
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    40
#include <unistd.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    41
#include <strings.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    42
#include <fstream>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    43
#define strnicmp strncasecmp
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    44
#define stricmp strcasecmp
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    45
#define _alloca alloca
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    46
#endif
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    47
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    48
static const TInt RofsbuildMajorVersion=2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    49
static const TInt RofsbuildMinorVersion=12;
617
3a747a240983 ROM Tools 12.2.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 609
diff changeset
    50
static const TInt RofsbuildPatchVersion=4;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    51
static TBool SizeSummary=EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    52
static TPrintType SizeWhere=EAlways;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    53
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    54
static TInt gHeaderType=1;			// EPOC header
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    55
static TInt MAXIMUM_THREADS = 128;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    56
static TInt DEFAULT_THREADS = 8;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    57
ECompression gCompress=ECompressionUnknown;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    58
TUint  gCompressionMethod=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    59
TInt gThreadNum = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    60
TInt gCPUNum = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    61
TBool gGenSymbols = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    62
TInt gCodePagingOverride = -1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    63
TInt gDataPagingOverride = -1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    64
TInt gLogLevel = 0;	// Information is logged based on logging level.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    65
// The default is 0. So all the existing logs are generated as if gLogLevel = 0.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    66
// If any extra information required, the log level must be appropriately supplied.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    67
// Currrently, file details in ROM (like, file name in ROM & host, file size, whether
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    68
// the file is hidden etc) are logged when gLogLevel >= LOG_LEVEL_FILE_DETAILS.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    69
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    70
TBool gUseCoreImage = EFalse; // command line option for using core image file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    71
string gImageFilename = "";	// instead of obey file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    72
TBool gEnableStdPathWarning = EFalse;// for in-correct destination path warning(executables).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    73
TBool gLowMem = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    74
extern TBool gDriveImage;		// to Support data drive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    75
string gDriveFilename = "";		// input drive oby filename.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    76
string filename;				// to store oby filename passed to Rofsbuild.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    77
TBool reallyHelp = EFalse;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    78
TBool gSmrImage = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    79
string gSmrFileName = "";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    80
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    81
//Cache global variables
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    82
bool gCache = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    83
bool gCleanCache = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    84
bool gNoCache = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    85
TBool gKeepGoing = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    86
void PrintVersion() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    87
	Print(EAlways,"\nROFSBUILD - Rofs/Datadrive image builder");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    88
	Print(EAlways, " V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    89
	Print(EAlways,Copyright);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    90
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    91
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    92
char HelpText[] = 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    93
	"Syntax: ROFSBUILD [options] obeyfilename(Rofs)\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    94
	"Option: -v verbose,  -?,  -s[log|screen|both] size summary\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    95
	"        -d<bitmask> set trace mask (DEB build only)\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    96
	"        -compress   compress executable files where possible\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    97
	"        -j<digit> do the main job with <digit> threads\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    98
	"        -symbols generate symbol file\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    99
	"        -compressionmethod none|inflate|bytepair to set the compression\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   100
	"              none     uncompress the image.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   101
	"              inflate  compress the image.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   102
	"              bytepair compress the image.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   103
	"        -coreimage <core image file>\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   104
	"        -cache allow the ROFSBUILD to reuse/generate cached executable files\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   105
	"        -nocache force the ROFSBUILD not to reuse/generate cached executable files\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   106
	"        -cleancache permanently remove all cached executable files\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   107
	"        -datadrive=<drive obyfile1>,<drive obyfile2>,... for driveimage creation\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   108
	"              user can also input rofs oby file if required to generate both.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   109
	"        -smr=<SMR obyfile1>,<SMR obyfile2>,... for SMR partition creation\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   110
	"        -loglevel<level>  level of information to log (valid levels are 0,1,2).\n"//Tools like Visual ROM builder need the host/ROM filenames, size & if the file is hidden.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   111
	"        -wstdpath   warn if destination path provided for a file is not the standard path\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   112
	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   113
"        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   114
"        -k     to enable keepgoing when duplicate files exist in oby\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   115
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   116
char ReallyHelpText[] =
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   117
"Log Level:\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   118
"        0  produce the default logs\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   119
"        1  produce file detail logs in addition to the default logs\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   120
"        2  logs e32 header attributes in addition to the level 1 details\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   121
void processParamfile(const string& aFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   122
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   123
Process the command line arguments and prints the helpful message if none are supplied.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   124
@param argc    - No. of argument.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   125
@param *argv[] - Arguments value.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   126
*/ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   127
void processCommandLine(int argc, char *argv[], TBool paramFileFlag = EFalse) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   128
	// If "-argfile" option is passed to rofsbuild, then process the parameters
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   129
	// specified in parameter-file first and then the options passed from the command-line.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   130
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   131
	string ParamFileArg("-ARGFILE=");	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   132
	if(paramFileFlag == EFalse) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   133
		for (int count = 1; count<argc; count++) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   134
			string paramFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   135
			//strupr(argv[count]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   136
			if(strnicmp(argv[count],ParamFileArg.c_str(),ParamFileArg.length()) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   137
				paramFile.assign(&argv[count][ParamFileArg.length()]);									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   138
				processParamfile(paramFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   139
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   140
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   141
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   142
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   143
	int i = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   144
	while (i<argc) {		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   145
#ifdef __LINUX__	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   146
		if (argv[i][0] == '-') 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   147
#else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   148
		if ((argv[i][0] == '-') || (argv[i][0] == '/'))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   149
#endif
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   150
		{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   151
			// switch
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   152
			if ((argv[i][1] & 0x20) == 'v')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   153
				H.iVerbose = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   154
			else if(strnicmp (argv[i], "-SMR=", 5) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   155
				if(argv[i][5]) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   156
					gSmrImage = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   157
					gSmrFileName.assign(&argv[i][5]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   158
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   159
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   160
					Print (EError, "SMR obey file is missing\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   161
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   162
			} else if (stricmp(argv[i], "-K") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   163
				gKeepGoing = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   164
			}else if (stricmp(argv[i], "-SYMBOLS") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   165
				gGenSymbols = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   166
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   167
			else if (((argv[i][1] | 0x20) == 's') &&  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   168
				(((argv[i][2]| 0x20) == 'l')||((argv[i][2] | 0x20) == 's'))) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   169
					SizeSummary = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   170
					if ((argv[i][2]| 0x20) == 'l')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   171
						SizeWhere = ELog;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   172
					else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   173
						SizeWhere = EScreen;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   174
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   175
			else if (strnicmp(argv[i],ParamFileArg.c_str(),ParamFileArg.length()) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   176
				if (paramFileFlag){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   177
					string paramFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   178
					paramFile.assign(&argv[i][ParamFileArg.length()]);		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   179
					processParamfile(paramFile);
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
					i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   183
					continue;
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
			else if (stricmp(argv[i], "-COMPRESS") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   187
				gCompress = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   188
				gCompressionMethod = KUidCompressionDeflate;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   189
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   190
			else if(stricmp(argv[i], "-CACHE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   191
				gCache = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   192
				if(gCleanCache || gNoCache) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   193
					printf("Cache command line options are mutually exclusive, only one option can be used at a time\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   194
					exit(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   195
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   196
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   197
			else if(stricmp(argv[i], "-NOCACHE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   198
				gNoCache = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   199
				if(gCleanCache || gCache) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   200
					printf("Cache command line options are mutually exclusive, only one option can be used at a time\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   201
					exit(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   202
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   203
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   204
			else if(stricmp(argv[i], "-CLEANCACHE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   205
				gCleanCache = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   206
				if(gCache || gNoCache)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   207
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   208
					printf("Cache command line options are mutually exclusive, only one option can be used at a time\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   209
					exit(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   210
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   211
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   212
			else if (strnicmp(argv[i], "-J",2) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   213
				if(argv[i][2])
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   214
					gThreadNum = atoi(&argv[i][2]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   215
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   216
					printf("WARNING: The option should be like '-j4'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   217
					gThreadNum = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   218
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   219
				if(gThreadNum <= 0 || gThreadNum > MAXIMUM_THREADS) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   220
					printf("WARNING: The number of concurrent jobs set by -j should be between 1 and 128. ");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   221
					if(gCPUNum > 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   222
						printf("WARNING: The number of processors %d is used as the number of concurrent jobs.\n", gCPUNum);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   223
						gThreadNum = gCPUNum;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   224
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   225
					else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   226
						printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   227
						gThreadNum = DEFAULT_THREADS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   228
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   229
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   230
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   231
			else if (stricmp(argv[i], "-UNCOMPRESS") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   232
				gCompress = ECompressionUncompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   233
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   234
			else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   235
				// next argument should a be method
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   236
				if( (i+1) >= argc || argv[i+1][0] == '-') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   237
					Print (EError, "Missing compression method! Set it to default (no compression)!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   238
					gCompressionMethod = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   239
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   240
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   241
					i++;					
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   242
					if( stricmp(argv[i], "NONE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   243
						gCompress = ECompressionUncompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   244
						gCompressionMethod = 0;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   245
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   246
					else if( stricmp(argv[i], "INFLATE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   247
						gCompress = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   248
						gCompressionMethod = KUidCompressionDeflate;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   249
					}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   250
					else if( stricmp(argv[i], "BYTEPAIR") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   251
						gCompress = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   252
						gCompressionMethod = KUidCompressionBytePair;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   253
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   254
					else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   255
						Print (EError, "Unknown compression method! Set it to default (no compression)!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   256
						gCompress = ECompressionUnknown;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   257
						gCompressionMethod = 0;		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   258
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   259
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   260
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   261
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   262
			else if (stricmp(argv[i], "-COREIMAGE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   263
				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   264
				gUseCoreImage = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   265
				// next argument should be image filename
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   266
				if ((i+1 >= argc) || argv[i+1][0] == '-')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   267
					Print (EError, "Missing image file name");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   268
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   269
					i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   270
					gImageFilename.assign(argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   271
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   272
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   273
			else if (strnicmp(argv[i], "-DATADRIVE=",11) == 0){  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   274
				if(argv[i][11])	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   275
					gDriveImage = ETrue; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   276
					gDriveFilename.assign(&argv[i][11]);	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   277
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   278
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   279
					Print (EError, "Drive obey file is missing\n"); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   280
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   281
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   282
			else if (argv[i][1] == '?') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   283
				reallyHelp = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   284
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   285
			else if (stricmp(argv[i], "-WSTDPATH") == 0)	{	// Warn if destination path provided for a executables are incorrect as per platsec.		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   286
				gEnableStdPathWarning = ETrue;						
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   287
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   288
			else if( stricmp(argv[i], "-LOGLEVEL") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   289
				// next argument should a be loglevel
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   290
				if( (i+1) >= argc || argv[i+1][0] == '-') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   291
					Print (EError, "Missing loglevel!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   292
					gLogLevel = DEFAULT_LOG_LEVEL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   293
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   294
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   295
					i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   296
					if (strcmp(argv[i], "2") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   297
						gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   298
					if (strcmp(argv[i], "1") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   299
						gLogLevel = LOG_LEVEL_FILE_DETAILS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   300
					else if (strcmp(argv[i], "0") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   301
						gLogLevel = DEFAULT_LOG_LEVEL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   302
					else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   303
						Print(EError, "Only loglevel 0, 1 or 2 is allowed!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   304
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   305
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   306
			else if( stricmp(argv[i], "-LOGLEVEL2") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   307
				gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   308
			else if( stricmp(argv[i], "-LOGLEVEL1") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   309
				gLogLevel = LOG_LEVEL_FILE_DETAILS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   310
			else if( stricmp(argv[i], "-LOGLEVEL0") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   311
				gLogLevel = DEFAULT_LOG_LEVEL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   312
			else if (stricmp(argv[i], "-LOWMEM") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   313
				gLowMem = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   314
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   315
#ifdef WIN32
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   316
				Print (EWarning, "Unrecognised option %s\n",argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   317
#else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   318
				if(0 == access(argv[i],R_OK)){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   319
					filename.assign(argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   320
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   321
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   322
					Print (EWarning, "Unrecognised option %s\n",argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   323
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   324
#endif				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   325
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   326
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   327
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   328
		else // Must be the obey filename
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   329
			filename.assign(argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   330
		i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   331
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   332
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   333
	if (paramFileFlag)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   334
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   335
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   336
	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   337
		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   338
			Print (EAlways, HelpText);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   339
			if (reallyHelp) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   340
				ObeyFileReader::KeywordHelp();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   341
				Print (EAlways, ReallyHelpText);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   342
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   343
			else if (filename.empty()){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   344
				Print(EAlways, "Obey filename is missing\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   345
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   346
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   347
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   348
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   349
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   350
Function to process parameter-file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   351
@param aFileName parameter-file name.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   352
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   353
void processParamfile(const string& aFileName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   354
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   355
	CParameterFileProcessor parameterFile(aFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   356
	// Invoke fuction "ParameterFileProcessor" to process parameter-file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   357
	if(parameterFile.ParameterFileProcessor()) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   358
		TUint noOfParameters = parameterFile.GetNoOfArguments();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   359
		char** parameters = parameterFile.GetParameters();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   360
		TBool paramFileFlag = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   361
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   362
		// Invoke function "processCommandLine" to process parameters read from parameter-file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   363
		processCommandLine(noOfParameters,parameters,paramFileFlag);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   364
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   365
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   366
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   367
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   368
Main logic for data drive image creation. Called many types depending on no. of drive obey files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   369
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   370
@param aobeyFileName - Drive obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   371
@param alogfile      - log file name required for file system module.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   372
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   373
@return - returns the status, after processing the drive obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   374
*/ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   375
TInt ProcessDataDriveMain(char* aobeyFileName,char* alogfile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   376
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   377
	ObeyFileReader *reader = new ObeyFileReader(aobeyFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   378
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   379
	if(!reader)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   380
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   381
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   382
	if(!reader->Open())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   383
		return KErrGeneral; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   384
		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   385
	CObeyFile* mainObeyFile = new CObeyFile(*reader);    
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   386
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   387
	if(!mainObeyFile)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   388
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   389
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   390
	// Process data drive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   391
	// let's clear the TRomNode::sDefaultInitialAttr first, 'cause data drive is different from rom image
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   392
	TRomNode::sDefaultInitialAttr = 0; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   393
	TInt retstatus = mainObeyFile->ProcessDataDrive();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   394
	if (retstatus == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   395
		// Build a Data drive image using the description compiled into the CObeyFile object
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   396
		CDriveImage* userImage = new CDriveImage(mainObeyFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   397
		if(userImage) {	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   398
			// Drive image creation.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   399
			retstatus = userImage->CreateImage(alogfile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   400
			if(retstatus == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   401
				Print (EAlways, "\nSuccessfully generated the Drive image : %s \n",mainObeyFile->iDriveFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   402
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   403
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   404
				Print (EError, "Failed to generate the Image : %s\n",mainObeyFile->iDriveFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   405
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   406
			delete userImage; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   407
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   408
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   409
			retstatus = KErrNoMemory;
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
	// restore
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   413
	TRomNode::sDefaultInitialAttr = (TUint8)KEntryAttReadOnly;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   414
	cout << "\n-----------------------------------------------------------\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   415
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   416
	delete mainObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   417
	delete reader;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   418
	return retstatus;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   419
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   420
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   421
TInt ProcessSmrImageMain(char* aObeyFileName, char* /* alogfile */) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   422
	ObeyFileReader *reader = new ObeyFileReader(aObeyFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   423
	if(!reader)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   424
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   425
	if(!reader->Open())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   426
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   427
	TInt retstatus = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   428
	CObeyFile* mainObeyFile = new CObeyFile(*reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   429
	CSmrImage* smrImage = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   430
	if(!mainObeyFile)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   431
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   432
	if(mainObeyFile->Process()) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   433
		smrImage = new CSmrImage(mainObeyFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   434
		if(smrImage) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   435
			if((retstatus = smrImage->Initialise()) == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   436
				retstatus = smrImage->CreateImage();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   437
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   438
			if(retstatus == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   439
				Print (EAlways,  "\nSuccessfully generated the SMR image : %s\n" ,smrImage->GetImageName().c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   440
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   441
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   442
				Print (EError, "\nFailed to generate the Image : %s\n" ,smrImage->GetImageName().c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   443
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   444
			delete smrImage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   445
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   446
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   447
			retstatus = KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   448
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   449
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   450
	delete mainObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   451
	delete reader;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   452
	return retstatus;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   453
}
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
Rofsbuild Main function, which creates both Rofs and Data drive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   457
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   458
@param argc    - No. of argument.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   459
@param *argv[] - Arguments value.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   460
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   461
@return - returns the status to caller.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   462
*/ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   463
TInt main(int argc, char *argv[]){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   464
	TInt r =0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   465
#ifdef __LINUX__
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   466
	gCPUNum = sysconf(_SC_NPROCESSORS_CONF);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   467
#else	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   468
	char* pCPUNum = getenv ("NUMBER_OF_PROCESSORS");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   469
	if (pCPUNum != NULL)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   470
		gCPUNum = atoi(pCPUNum);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   471
#endif		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   472
	if(gCPUNum > MAXIMUM_THREADS)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   473
		gCPUNum = MAXIMUM_THREADS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   474
	PrintVersion();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   475
	processCommandLine(argc, argv);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   476
	//if the user wants to clean up the cache, do it only.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   477
	if(gCleanCache){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   478
		try {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   479
			CacheManager::GetInstance()->CleanCache();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   480
			Print (EAlways, "Cache has been deleted successfully.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   481
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   482
		catch(CacheException& ce){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   483
			Print (EError, "%s\n", ce.GetErrorMessage());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   484
			return (TInt)1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   485
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   486
		return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   487
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   488
	//initialize cache if the user switches on.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   489
	if(gCache) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   490
		try {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   491
			CacheManager::GetInstance();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   492
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   493
		catch(CacheException ce){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   494
			Print (EError, "%s\n", ce.GetErrorMessage());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   495
			return (TInt)1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   496
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   497
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   498
	const char *obeyFileName = 0;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   499
	if(!filename.empty())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   500
		obeyFileName = filename.c_str(); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   501
	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   502
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   503
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   504
	if(gThreadNum == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   505
		if(gCPUNum > 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   506
			Print (EWarning, "The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   507
			gThreadNum = gCPUNum;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   508
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   509
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   510
			Print (EWarning, "Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   511
			gThreadNum = DEFAULT_THREADS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   512
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   513
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   514
	// Process drive obey files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   515
	if(gDriveImage) {  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   516
		char temp = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   517
		char *driveobeyFileName = (char*)_alloca(gDriveFilename.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   518
		memcpy(driveobeyFileName,gDriveFilename.c_str(),gDriveFilename.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   519
		char* ptr = driveobeyFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   520
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   521
			while(((temp = *ptr++) != ',') && (temp != 0));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   522
			*(--ptr)++ = 0; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   523
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   524
			if(*driveobeyFileName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   525
				char* logfile = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   526
				if(Getlogfile(driveobeyFileName,logfile) == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   527
					H.SetLogFile(logfile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   528
					GetLocalTime();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   529
					r = ProcessDataDriveMain(driveobeyFileName,logfile);   
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   530
					H.CloseLogFile();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   531
					delete[] logfile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   532
					if(r == KErrNoMemory)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   533
						return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   534
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   535
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   536
					Print(EError,"Invalid obey file name : %s\n", driveobeyFileName);   
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   537
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   538
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   539
			driveobeyFileName = ptr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   540
		} while(temp != 0); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   541
		gDriveImage = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   542
	} 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   543
	if(gSmrImage){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   544
		char temp = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   545
		char *smrImageObeyFileName = (char*)_alloca(gSmrFileName.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   546
		memcpy(smrImageObeyFileName,gSmrFileName.c_str(),gSmrFileName.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   547
		char* ptr = smrImageObeyFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   548
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   549
			while(((temp = *ptr++) != ',') && (temp != 0));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   550
			*(--ptr)++ = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   551
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   552
			if(*smrImageObeyFileName){	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   553
				char * logfile = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   554
				if(Getlogfile(smrImageObeyFileName,logfile) == KErrNone){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   555
					H.SetLogFile(logfile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   556
					GetLocalTime();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   557
					r = ProcessSmrImageMain(smrImageObeyFileName, logfile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   558
					H.CloseLogFile();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   559
					delete[] logfile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   560
					if(r == KErrNoMemory)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   561
						return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   562
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   563
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   564
					Print(EError,"Invalid obey file name: %s", smrImageObeyFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   565
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   566
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   567
			smrImageObeyFileName = ptr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   568
		} while(temp != 0);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   569
		gSmrImage = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   570
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   571
	// Process Rofs Obey files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   572
	if(obeyFileName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   573
		H.SetLogFile("ROFSBUILD.LOG");		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   574
		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   575
		if (!reader->Open())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   576
			return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   577
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   578
		E32Rofs* RofsImage = 0;		// for image from obey file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   579
		CCoreImage *core = 0;		// for image from core image file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   580
		MRofsImage* imageInfo = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   581
		CObeyFile *mainObeyFile = new CObeyFile(*reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   582
		// need check if obey file has coreimage keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   583
		char *file = mainObeyFile->ProcessCoreImage();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   584
		if (file) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   585
			// hase coreimage keyword but only use if command line option
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   586
			// for coreimage not already selected
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   587
			if (!gUseCoreImage){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   588
				gUseCoreImage = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   589
				gImageFilename = file;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   590
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   591
			delete []file ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   592
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   593
		if (!gUseCoreImage) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   594
			r = mainObeyFile->ProcessRofs();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   595
			if (r == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   596
				// Build a ROFS image using the description compiled into the CObeyFile object
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   597
				RofsImage = new E32Rofs( mainObeyFile );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   598
				if( !RofsImage ) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   599
					if(gCache || gCleanCache)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   600
						delete CacheManager::GetInstance();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   601
					return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   602
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   603
				r = RofsImage->Create();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   604
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   605
				if( KErrNone == r )	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   606
					RofsImage->WriteImage( gHeaderType );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   607
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   608
				imageInfo = RofsImage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   609
				mainObeyFile->Release();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   610
				if(gCache || gCleanCache)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   611
					delete CacheManager::GetInstance();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   612
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   613
			else if (r != KErrNotFound){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   614
				return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   615
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   616
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   617
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   618
			// need to use core image
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   619
			RCoreImageReader *reader = new RCoreImageReader(gImageFilename.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   620
			if (!reader) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   621
				return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   622
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   623
			core = new CCoreImage(reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   624
			if (!core) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   625
				return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   626
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   627
			r = core->ProcessImage();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   628
			if (r != KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   629
				return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   630
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   631
			imageInfo = core;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   632
			mainObeyFile->SkipToExtension();
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
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   636
			CObeyFile* extensionObeyFile = new CObeyFile(*reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   637
			r = extensionObeyFile->ProcessExtensionRofs(imageInfo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   638
			if (r == KErrEof){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   639
				if(RofsImage){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   640
					delete RofsImage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   641
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   642
				if(core){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   643
					delete core;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   644
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   645
				delete extensionObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   646
				return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   647
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   648
			if (r != KErrNone){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   649
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   650
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   651
			E32Rofs* extensionRofs = new E32Rofs(extensionObeyFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   652
			r = extensionRofs->CreateExtension(imageInfo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   653
			if (r!= KErrNone){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   654
				delete extensionRofs;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   655
				delete extensionObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   656
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   657
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   658
			r = extensionRofs->WriteImage(0);	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   659
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   660
			delete extensionRofs;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   661
			extensionRofs = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   662
		} while (r == KErrNone);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   663
		if(RofsImage) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   664
			delete RofsImage;									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   665
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   666
		if(core){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   667
			delete core;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   668
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   669
		delete mainObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   670
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   671
	return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   672
}//end of main.