imgtools/romtools/rofsbuild/r_obey.cpp
author jjkang
Tue, 29 Jun 2010 14:52:54 +0800
changeset 606 30b30f9da0b7
parent 0 044383f39525
child 607 378360dbbdba
permissions -rw-r--r--
Add ..\dev\.. to path
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) 1995-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
* @internalComponent * @released
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    16
* Rofsbuild Obey file class and its reader class.
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
 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    20
#include <strstream>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    21
#include <iomanip>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    22
 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    23
#include <string.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    24
#include <stdlib.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    25
#include <stdio.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    26
#include <time.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    27
#include <assert.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    28
#include <errno.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    29
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    30
#include <e32std.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    31
#include <e32std_private.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    32
#include <e32rom.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    33
#include <u32std.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    34
#include <f32file.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    35
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    36
#include "h_utl.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    37
#include "r_obey.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    38
#include "r_coreimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    39
#include "patchdataprocessor.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    40
#include "fatimagegenerator.h" 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    41
#include "r_driveimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    42
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    43
extern TInt gCodePagingOverride;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    44
extern TInt gDataPagingOverride;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    45
extern ECompression gCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    46
extern TBool gEnableStdPathWarning; // Default to not warn if destination path provided for a file is not in standard path.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    47
extern TBool gKeepGoing;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    48
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    49
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    50
#define _P(word)	word, sizeof(word)-1	// match prefix, optionally followed by [HWVD]
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    51
#define _K(word)	word, 0					// match whole word
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    52
static char* const NullString = "" ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    53
const ObeyFileKeyword ObeyFileReader::iKeywords[] =
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    54
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    55
	{_K("file"),		2,-2, EKeywordFile, "File to be copied into ROFS"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    56
	{_K("data"),		2,-2, EKeywordData, "same as file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    57
	{_K("dir"),         2,1, EKeywordDir, "Directory to be created into FAT image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    58
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    59
	{_K("rofsname"),	1, 1, EKeywordRofsName, "output file for ROFS image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    60
	{_K("romsize"),		1, 1, EKeywordRomSize, "size of ROM image"}, 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    61
	{_P("hide"),	    2, -1, EKeywordHide, "Exclude named file from ROM directory structure"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    62
	{_P("alias"),	    2, -2, EKeywordAlias, "Create alias for existing file in ROM directory structure"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    63
	{_P("rename"),	    2, -2, EKeywordRename, "Change the name of a file in the ROM directory structure"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    64
	{_K("rofssize"),		1, 1, EKeywordRofsSize, "maximum size of ROFS image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    65
	{_K("romchecksum"),	1, 1, EKeywordRofsChecksum, "desired 32-bit checksum value for the whole image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    66
	{_K("version"),		1, 1, EKeywordVersion, "ROFS image version number"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    67
	{_K("time"),	    1,-1, EKeywordTime, "ROFS image timestamp"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    68
	{_K("extensionrofs"),1+2, 1, EKeywordExtensionRofs, "Start of definition of optional Extension ROFS"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    69
	{_K("extensionrofsname"),1, 1, EKeywordCoreRofsName, "ROFS image on which extension ROFS is based"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    70
	{_K("rem"),			0, 0, EKeywordNone, "comment"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    71
	{_K("stop"),		0, 0, EKeywordNone, "Terminates OBEY file prematurely"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    72
	{_K("romchecksum"),	1, 1, EKeywordRomChecksum, "desired 32-bit checksum value for the whole ROFS image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    73
	{_K("coreimage"),	1, 1, EKeywordCoreImage, "Core image to be used for extension directory structure"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    74
	{_K("autosize"),	1, 1, EKeywordRofsAutoSize, "Automatically adjust maximum image size to actual used"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    75
	{_K("pagingoverride"),	1, 1, EKeywordPagingOverride, "Overide the demand paging attributes for every file in ROM, NOPAGING|DEFAULTUNPAGED|DEFAULTPAGED"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    76
	{_K("codepagingoverride"),	1, 1, EKeywordCodePagingOverride, "Overide the code paging attributes for every file in ROM, NOPAGING|DEFAULTUNPAGED|DEFAULTPAGED"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    77
	{_K("datapagingoverride"),	1, 1, EKeywordDataPagingOverride, "Overide the data paging attributes for every file in ROM, NOPAGING|DEFAULTUNPAGED|DEFAULTPAGED"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    78
	{_K("dataimagename"),1, 1,EKeywordDataImageName, "Data Drive image file name"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    79
	{_K("dataimagefilesystem"),1, 1,EKeywordDataImageFileSystem, "Drive image file system format"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    80
	{_K("dataimagesize"),1, 1,EKeywordDataImageSize, "Maximum size of Data Drive image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    81
	{_K("volume"),1, -1,EKeywordDataImageVolume, "Volume Label of Data Drive image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    82
	{_K("sectorsize"),1, 1,EKeywordDataImageSectorSize, "Sector size(in bytes) of Data Drive image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    83
	{_K("fattable"),1, 1,EKeywordDataImageNoOfFats, "Number of FATs in the Data Drive image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    84
	// things we don't normally report in the help information
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    85
	{_K("trace"),		1, 1, EKeywordTrace, "(ROMBUILD activity trace flags)"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    86
	{_K("filecompress"),2, -2,EKeywordFileCompress,"Non-XIP Executable to be loaded into the ROM compressed" },
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    87
	{_K("fileuncompress"),2, -2,EKeywordFileUncompress,"Non-XIP Executable to be loaded into the ROM uncompressed" },
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    88
	{_K("patchdata"),2, 5,EKeywordPatchDllData, "Patch exported data"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    89
	{_K("imagename"), 1, 1, EKeywordSmrImageName, "output file for SMR image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    90
	{_K("hcrdata"), 1, 1, EKeywordSmrFileData, "file data for HCR SMR image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    91
	{_K("formatversion"), 1, 1, EKeywordSmrFormatVersion, "format version for HCR SMR image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    92
	{_K("payloadflags"), 1, 1, EKeywordSmrFlags, "payload flags for the HCR SMR image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    93
	{_K("payloaduid"), 1, 1, EKeywordSmrUID, "payload UID for the HCR SMR image"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    94
	{0,0,0,0,EKeywordNone,""}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    95
};
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    96
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    97
void ObeyFileReader::KeywordHelp() { // static
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    98
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    99
	cout << "Obey file keywords:\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   100
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   101
	const ObeyFileKeyword* k=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   102
	for (k=iKeywords; k->iKeyword!=0; k++)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   103
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   104
		if (k->iHelpText == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   105
			continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   106
		if (k->iHelpText[0]=='(' && !H.iVerbose)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   107
			continue;	// don't normally report things in (parentheses)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   108
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   109
		char buf[32];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   110
		sprintf(buf, "%-20s", k->iKeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   111
		if (k->iKeywordLength)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   112
			memcpy(buf+k->iKeywordLength,"[HWVD]",6);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   113
		if (H.iVerbose)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   114
			sprintf(buf+20,"%2d",k->iNumArgs);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   115
		cout << "    " << buf << " " << k->iHelpText << endl;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   116
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   117
	cout << endl;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   118
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   119
	cout << "File attributes:\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   120
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   121
	const FileAttributeKeyword* f=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   122
	for (f=iAttributeKeywords; f->iKeyword!=0; f++)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   123
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   124
		if (f->iHelpText == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   125
			continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   126
		if (f->iHelpText[0]=='(' && !H.iVerbose)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   127
			continue;	// don't normally report things in (parentheses)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   128
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   129
		char buf[32];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   130
		sprintf(buf, "%-20s", f->iKeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   131
		if (H.iVerbose)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   132
			sprintf(buf+20,"%2d",k->iNumArgs);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   133
		cout << "    " << buf << " " << f->iHelpText << endl;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   134
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   135
	cout << endl;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   136
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   137
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   138
ObeyFileReader::ObeyFileReader(const char* aFileName):iCurrentLine(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   139
iFileName(aFileName),iNumWords(0),iLine(0),iMarkLine(0),iCurrentObeyStatement(0)	{  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   140
	for(TUint i = 0 ; i < KNumWords ; i++)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   141
		iWord[i] = NullString;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   142
	*iSuffix = 0 ; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   143
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   144
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   145
ObeyFileReader::~ObeyFileReader() {	  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   146
	if(iCurrentObeyStatement) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   147
		delete []iCurrentObeyStatement;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   148
		iCurrentObeyStatement = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   149
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   150
	if(iLine) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   151
		delete []iLine; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   152
		iLine = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   153
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   154
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   155
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   156
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   157
// Open the file & return a status
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   158
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   159
TBool ObeyFileReader::Open() {     
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   160
	ifstream ifs(iFileName.c_str(),ios_base::in + ios_base::binary);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   161
	if (!ifs.is_open()) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   162
		Print(EError,"Cannot open obey file %s\n",iFileName.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   163
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   164
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   165
	iLines.clear();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   166
	if(iLine){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   167
		delete []iLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   168
		iLine = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   169
	}		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   170
	ifs.seekg(0,ios_base::end);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   171
	size_t length = ifs.tellg();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   172
	char* buffer = new char[length + 2];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   173
	if (0 == buffer) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   174
		Print(EError,"Insufficent Memory to Continue.");	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   175
		ifs.close();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   176
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   177
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   178
	ifs.seekg(0,ios_base::beg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   179
	ifs.read(buffer,length);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   180
	size_t readcout = ifs.gcount() ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   181
	if(readcout != length){ 	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   182
		Print(EError,"Cannot Read All of File.");	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   183
		delete []buffer ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   184
		ifs.close();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   185
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   186
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   187
	buffer[length] = '\n';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   188
	buffer[length + 1] = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   189
	ifs.close();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   190
	char* lineStart = buffer ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   191
	char* end = buffer + length ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   192
	string line ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   193
	size_t maxLengthOfLine = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   194
	while(lineStart < end){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   195
		while(*lineStart == ' ' || *lineStart == '\t') //trimleft 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   196
			lineStart ++ ;		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   197
		char* lineEnd = lineStart ;	 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   198
		while(*lineEnd != '\r' && *lineEnd != '\n')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   199
			lineEnd ++ ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   200
		if(strnicmp(lineStart,"REM",3) == 0){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   201
			line = "" ; // REMOVE "REM ... "
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   202
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   203
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   204
			TInt lastIndex = lineEnd - lineStart - 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   205
			while(lastIndex >= 0 &&  // trimright
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   206
				(lineStart[lastIndex] == ' ' || lineStart[lastIndex] == '\t'))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   207
				lastIndex -- ;			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   208
			if(lastIndex >= 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   209
				line.assign(lineStart,lastIndex + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   210
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   211
				line = "";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   212
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   213
		if(line.length() > maxLengthOfLine)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   214
			maxLengthOfLine = line.length();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   215
		iLines.push_back(line);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   216
		if(*lineEnd == '\r') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   217
			if(lineEnd[1] == '\n')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   218
				lineStart = lineEnd + 2 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   219
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   220
				lineStart = lineEnd + 1 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   221
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   222
		else // '\n'
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   223
			lineStart = lineEnd + 1 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   224
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   225
	delete []buffer ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   226
	iLine = new char[maxLengthOfLine + 1];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   227
	iCurrentObeyStatement = new char[maxLengthOfLine + 1];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   228
	*iCurrentObeyStatement = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   229
	*iLine = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   230
	iCurrentLine = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   231
	iMarkLine = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   232
	return ETrue;
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
void ObeyFileReader::Mark()	{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   236
	iMarkLine = iCurrentLine - 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   237
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   238
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   239
void ObeyFileReader::MarkNext() { 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   240
	iMarkLine = iCurrentLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   241
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   242
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   243
void ObeyFileReader::Rewind() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   244
	iCurrentLine = iMarkLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   245
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   246
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   247
char* ObeyFileReader::DupWord(TInt aIndex) const {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   248
	char* retVal = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   249
	if(aIndex >= 0 && aIndex < (TInt)KNumWords){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   250
		size_t len = strlen(iWord[aIndex]) + 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   251
		retVal = new char[len];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   252
		if(retVal)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   253
			memcpy(retVal,iWord[aIndex],len);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   254
	} 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   255
	return retVal ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   256
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   257
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   258
TInt ObeyFileReader::ReadAndParseLine() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   259
	if (iCurrentLine >= (TInt)iLines.size())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   260
		return KErrEof;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   261
	iCurrentLine++; 	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   262
	iNumWords = Parse();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   263
	return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   264
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   265
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   266
TInt ObeyFileReader::NextLine(TInt aPass, enum EKeyword& aKeyword) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   267
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   268
NextLine:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   269
	TInt err = ReadAndParseLine();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   270
	if (err == KErrEof)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   271
		return KErrEof;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   272
	if(iNumWords == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   273
		goto NextLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   274
	if (stricmp(iWord[0], "stop")==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   275
		return KErrEof;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   276
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   277
	const ObeyFileKeyword* k=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   278
	for (k=iKeywords; k->iKeyword!=0; k++) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   279
		if (k->iKeywordLength == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   280
			// Exact case-insensitive match on keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   281
			if (stricmp(iWord[0], k->iKeyword) != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   282
				continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   283
			*iSuffix = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   284
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   285
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   286
			// Prefix match
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   287
			if (strnicmp(iWord[0], k->iKeyword, k->iKeywordLength) != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   288
				continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   289
			// Suffix must be empty, or a variant number in []
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   290
			strncpy(iSuffix,iWord[0] + k->iKeywordLength,80);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   291
			if (*iSuffix != '\0' && *iSuffix != '[')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   292
				continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   293
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   294
		// found a match
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   295
		if ((k->iPass & aPass) == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   296
			goto NextLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   297
		if (k->iNumArgs>=0 && (1+k->iNumArgs != iNumWords)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   298
			Print(EError, "Incorrect number of arguments for keyword %s on line %d.\n",
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   299
				iWord[0], iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   300
			goto NextLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   301
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   302
		if (k->iNumArgs<0 && (1-k->iNumArgs > iNumWords)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   303
			Print(EError, "Too few arguments for keyword %s on line %d.\n",
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   304
				iWord[0], iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   305
			goto NextLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   306
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   307
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   308
		aKeyword = k->iKeywordEnum;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   309
		return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   310
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   311
	if (aPass == 1)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   312
		Print(EWarning, "Unknown keyword '%s'.  Line %d ignored\n", iWord[0], iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   313
	goto NextLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   314
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   315
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   316
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   317
// splits a line into words, and returns the number of words found
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   318
// 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   319
TInt ObeyFileReader::Parse() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   320
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   321
	for (TUint i = 0; i < KNumWords; i++)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   322
		iWord[i] = NullString;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   323
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   324
	enum TState {EInWord, EInQuotedWord, EInGap};
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   325
	TState state = EInGap;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   326
	const string& line = iLines[iCurrentLine - 1]; 	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   327
	size_t len = line.length();	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   328
	memcpy(iLine,line.c_str(),len);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   329
	memcpy(iCurrentObeyStatement,iLine,len);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   330
	iLine[len] = 0 ; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   331
	iCurrentObeyStatement[len] = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   332
	TUint i = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   333
	char* linestr = iLine;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   334
	while (i < KNumWords && *linestr != 0) {	 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   335
		switch (state)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   336
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   337
		case EInGap:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   338
			if (*linestr =='\"') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   339
				if (linestr[1] != 0 && linestr[1]!='\"')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   340
					iWord[i++] = linestr + 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   341
				state = EInQuotedWord;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   342
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   343
			else if (!IsGap(*linestr)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   344
				iWord[i++] = linestr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   345
				state=EInWord;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   346
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   347
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   348
				*linestr=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   349
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   350
		case EInWord:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   351
			if (*linestr == '\"') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   352
				*linestr = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   353
				if (linestr[1] != 0 && linestr[1] != '\"')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   354
					iWord[i++] = linestr+1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   355
				state=EInQuotedWord;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   356
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   357
			else if (IsGap(*linestr)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   358
				*linestr=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   359
				state=EInGap;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   360
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   361
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   362
		case EInQuotedWord:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   363
			if (*linestr == '\"'){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   364
				*linestr = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   365
				state = EInGap;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   366
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   367
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   368
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   369
		linestr++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   370
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   371
	return i;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   372
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   373
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   374
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   375
// Process the timestamp
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   376
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   377
void ObeyFileReader::ProcessTime(TInt64& aTime) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   378
	char timebuf[256];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   379
	if (iNumWords>2)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   380
		sprintf(timebuf, "%s_%s", iWord[1], iWord[2]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   381
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   382
		strncpy(timebuf, iWord[1],256);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   383
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   384
	TInt r = StringToTime(aTime, timebuf);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   385
	if (r==KErrGeneral) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   386
		Print(EError, "incorrect format for time keyword on line %d\n", iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   387
		exit(0x670);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   388
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   389
	if (r==KErrArgument){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   390
		Print(EError, "Time out of range on line %d\n", iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   391
		exit(0x670);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   392
	}
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
TInt64 ObeyFileReader::iTimeNow = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   396
void ObeyFileReader::TimeNow(TInt64& aTime) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   397
	if (iTimeNow==0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   398
		TInt sysTime = time(0);					// seconds since midnight Jan 1st, 1970
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   399
		sysTime -= (30*365*24*60*60+7*24*60*60);	// seconds since midnight Jan 1st, 2000
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   400
		TInt64 daysTo2000AD=730497;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   401
		TInt64 t=daysTo2000AD*24*3600+sysTime;	// seconds since 0000
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   402
		t = t+3600;								// BST (?)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   403
		iTimeNow=t*1000000;						// milliseconds
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   404
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   405
	aTime=iTimeNow;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   406
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   407
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   408
 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   409
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   410
// File attributes.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   411
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   412
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   413
const FileAttributeKeyword ObeyFileReader::iAttributeKeywords[] =
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   414
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   415
	{"attrib",3			,0,1,EAttributeAtt, "File attributes in ROM file system"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   416
	{"exattrib",3		,0,1,EAttributeAttExtra, "File extra attributes in ROM file system"}, 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   417
	{"stack",3			,1,1,EAttributeStack, "?"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   418
	{"fixed",3			,1,0,EAttributeFixed, "Relocate to a fixed address space"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   419
	{"priority",3		,1,1,EAttributePriority, "Override process priority"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   420
	{_K("uid1")			,1,1,EAttributeUid1, "Override first UID"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   421
	{_K("uid2")			,1,1,EAttributeUid2, "Override second UID"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   422
	{_K("uid3")			,1,1,EAttributeUid3, "Override third UID"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   423
	{_K("heapmin")		,1,1,EAttributeHeapMin, "Override initial heap size"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   424
	{_K("heapmax")		,1,1,EAttributeHeapMax, "Override maximum heap size"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   425
	{_K("capability")	,1,1,EAttributeCapability, "Override capabilities"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   426
	{_K("unpaged")		,1,0,EAttributeUnpaged, "Don't page code or data for this file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   427
	{_K("paged")		,1,0,EAttributePaged, "Page code and data for this file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   428
	{_K("unpagedcode")	,1,0,EAttributeUnpagedCode, "Don't page code for this file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   429
	{_K("pagedcode")	,1,0,EAttributePagedCode, "Page code for this file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   430
	{_K("unpageddata")	,1,0,EAttributeUnpagedData, "Don't page data for this file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   431
	{_K("pageddata")	,1,0,EAttributePagedData, "Page data for this file"},
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   432
	{0,0,0,0,EAttributeAtt,0}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   433
};
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   434
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   435
TInt ObeyFileReader::NextAttribute(TInt& aIndex, TInt aHasFile, enum EFileAttribute& aKeyword, char*& aArg)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   436
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   437
NextAttribute:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   438
	if (aIndex >= iNumWords)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   439
		return KErrEof;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   440
	char* word=iWord[aIndex++];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   441
	const FileAttributeKeyword* k;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   442
	for (k=iAttributeKeywords; k->iKeyword!=0; k++)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   443
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   444
		if (k->iKeywordLength == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   445
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   446
			// Exact match on keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   447
			if (stricmp(word, k->iKeyword) != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   448
				continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   449
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   450
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   451
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   452
			// Prefix match
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   453
			if (strnicmp(word, k->iKeyword, k->iKeywordLength) != 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   454
				continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   455
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   456
		// found a match
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   457
		if (k->iNumArgs>0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   458
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   459
			TInt argIndex = aIndex;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   460
			aIndex += k->iNumArgs;		// interface only really supports 1 argument
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   461
			if (aIndex>iNumWords)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   462
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   463
				Print(EError, "Missing argument for attribute %s on line %d\n", word, iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   464
				return KErrArgument;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   465
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   466
			aArg=iWord[argIndex];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   467
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   468
		if (k->iIsFileAttribute && !aHasFile)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   469
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   470
			Print(EError, "File attribute %s applied to non-file on line %d\n", word, iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   471
			return KErrNotSupported;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   472
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   473
		aKeyword=k->iAttributeEnum;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   474
		return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   475
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   476
	Print(EWarning, "Unknown attribute '%s' skipped on line %d\n", word, iCurrentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   477
	goto NextAttribute;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   478
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   479
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   480
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
Constructor:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   484
1.Obey file instance.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   485
2.used by both rofs and datadrive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   486
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   487
@param aReader - obey file reader object.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   488
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   489
CObeyFile::CObeyFile(ObeyFileReader& aReader):
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   490
iRomFileName(NULL),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   491
iExtensionRofsName(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   492
iKernelRofsName(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   493
iRomSize(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   494
iVersion(0,0,0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   495
iCheckSum(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   496
iNumberOfFiles(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   497
iTime(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   498
iRootDirectory(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   499
iNumberOfDataFiles(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   500
iDriveFileName(0), 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   501
iDriveFileFormat(0), 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   502
iReader(aReader), 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   503
iMissingFiles(0), 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   504
iLastExecutable(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   505
iFirstFile(0), 	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   506
iCurrentFile(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   507
iAutoSize(EFalse),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   508
iAutoPageSize(4096),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   509
iPagingOverrideParsed(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   510
iCodePagingOverrideParsed(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   511
iDataPagingOverrideParsed(0),
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   512
iPatchData(new CPatchDataProcessor)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   513
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   514
	iNextFilePtrPtr = &iFirstFile ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   515
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   516
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   517
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   518
Obey file Destructor.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   519
1.Release the tree memory.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   520
2.Release all allocated memory if any.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   521
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   522
CObeyFile::~CObeyFile() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   523
	if(iDriveFileName){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   524
		delete[] iDriveFileName;					
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   525
		iDriveFileName = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   526
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   527
	if(iDriveFileFormat) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   528
		delete[] iDriveFileFormat;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   529
		iDriveFileFormat = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   530
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   531
	iRootDirectory->deleteTheFirstNode();                
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   532
	iRootDirectory->InitializeCount();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   533
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   534
	Release();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   535
	if(iRomFileName){ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   536
		delete [] iRomFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   537
		iRomFileName = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   538
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   539
	if (iRootDirectory)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   540
		iRootDirectory->Destroy(); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   541
	if(iPatchData)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   542
		delete iPatchData;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   543
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   544
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   545
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   546
// Free resources not needed after building a ROM
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   547
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   548
void CObeyFile::Release() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   549
	iFirstFile = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   550
	iNextFilePtrPtr = &iFirstFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   551
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   552
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   553
TRomBuilderEntry *CObeyFile::FirstFile() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   554
	iCurrentFile = iFirstFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   555
	return iCurrentFile;
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
TRomBuilderEntry *CObeyFile::NextFile() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   559
	iCurrentFile = iCurrentFile ? iCurrentFile->iNext : 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   560
	return iCurrentFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   561
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   562
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   563
char* CObeyFile::ProcessCoreImage() const {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   564
	// check for coreimage keyword and return filename	 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   565
	enum EKeyword keyword;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   566
	char* coreImageFileName = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   567
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   568
	while (iReader.NextLine(1,keyword) != KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   569
		if (keyword == EKeywordCoreImage) {  			  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   570
			coreImageFileName = iReader.DupWord(1);	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   571
			iReader.MarkNext();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   572
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   573
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   574
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   575
	return coreImageFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   576
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   577
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   578
void CObeyFile::SkipToExtension() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   579
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   580
	enum EKeyword keyword;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   581
	while (iReader.NextLine(1,keyword) != KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   582
		if (keyword == EKeywordExtensionRofs) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   583
			iReader.Mark(); // ready for processing extension
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   584
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   585
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   586
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   587
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   588
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   589
TInt CObeyFile::ProcessRofs() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   590
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   591
	//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   592
	// First pass through the obey file to set up key variables
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   593
	//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   594
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   595
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   596
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   597
	TInt count=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   598
	enum EKeyword keyword;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   599
	while (iReader.NextLine(1,keyword) != KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   600
		if (keyword == EKeywordExtensionRofs){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   601
			if (count==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   602
				return KErrNotFound;		// no core ROFS, just extension ROFSs.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   603
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   604
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   605
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   606
		count++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   607
		if (! ProcessKeyword(keyword))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   608
			return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   609
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   610
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   611
	if (!GotKeyVariables())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   612
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   613
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   614
	//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   615
	// second pass to process the file specifications in the obey file building
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   616
	// up the TRomNode directory structure and the TRomBuilderEntry list
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   617
	//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   618
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   619
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   620
	iRootDirectory = new TRomNode("");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   621
	iLastExecutable = iRootDirectory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   622
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   623
	TInt align=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   624
	while (iReader.NextLine(2,keyword)!=KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   625
		if (keyword == EKeywordExtensionRofs)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   626
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   627
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   628
		if (keyword == EKeywordHide)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   629
			keyword = EKeywordHideV2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   630
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   631
		switch (keyword) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   632
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   633
		case EKeywordHide:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   634
		case EKeywordAlias:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   635
		case EKeywordRename:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   636
			if (!ProcessRenaming(keyword))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   637
				return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   638
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   639
		case EKeywordPatchDllData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   640
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   641
				// Collect patchdata statements to process at the end
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   642
				StringVector patchDataTokens;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   643
				SplitPatchDataStatement(patchDataTokens); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   644
				iPatchData->AddPatchDataStatement(patchDataTokens);									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   645
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   646
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   647
		default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   648
			if (!ProcessFile(align, keyword))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   649
				return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   650
			align=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   651
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   652
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   653
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   654
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   655
	if(!ParsePatchDllData())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   656
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   657
	iReader.Mark();			// ready for processing the extension rom(s)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   658
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   659
	if (iMissingFiles!=0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   660
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   661
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   662
	if ( 0 == iNumberOfFiles ){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   663
		Print(EError, "No files specified.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   664
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   665
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   666
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   667
	return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   668
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   669
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   670
TBool CObeyFile::Process() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   671
	TBool result = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   672
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   673
	enum EKeyword keyword;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   674
	while(iReader.NextLine(1, keyword) != KErrEof){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   675
		string key = iReader.Word(0);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   676
		string value = iReader.Word(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   677
		if(iKeyValues.find(key) != iKeyValues.end()){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   678
			iKeyValues[key].push_back(value);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   679
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   680
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   681
			StringVector values;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   682
			values.push_back(value);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   683
			iKeyValues[key]=values;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   684
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   685
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   686
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   687
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   688
	return result;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   689
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   690
StringVector CObeyFile::getValues(const string& aKey) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   691
	StringVector values;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   692
	if(iKeyValues.find(aKey) != iKeyValues.end()){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   693
		values = iKeyValues[aKey];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   694
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   695
	return values;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   696
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   697
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   698
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   699
Process drive obey file and construct the tree.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   700
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   701
@return - Return the status,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   702
'KErrnone' for Success,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   703
'KErrGeneral' for failure (required keywords not there in obey file or failed
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   704
to construct the tree).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   705
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   706
TInt CObeyFile::ProcessDataDrive() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   707
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   708
	enum EKeyword keyword;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   709
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   710
	// First pass through the obey file to set up key variables
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   711
	while (iReader.NextLine(1,keyword) != KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   712
		if (!ProcessDriveKeyword(keyword))			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   713
			return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   714
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   715
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   716
	if (!GotKeyDriveVariables())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   717
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   718
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   719
	// Second pass to process the file specifications in the obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   720
	// Build the TRomNode directory structure and the TRomBuilderEntry list
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   721
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   722
	iRootDirectory = new TRomNode("//");					
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   723
	iLastExecutable = iRootDirectory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   724
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   725
	while(iReader.NextLine(2,keyword)!=KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   726
		switch (keyword) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   727
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   728
		case EKeywordPatchDllData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   729
			{	// Collect patchdata statements to process at the end
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   730
				StringVector patchDataTokens;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   731
				SplitPatchDataStatement(patchDataTokens); 				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   732
				iPatchData->AddPatchDataStatement(patchDataTokens);									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   733
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   734
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   735
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   736
		case EKeywordHide:						
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   737
		case EKeywordFile:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   738
		case EKeywordDir:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   739
		case EKeywordData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   740
		case EKeywordFileCompress:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   741
		case EKeywordFileUncompress:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   742
			if (!ProcessDriveFile(keyword))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   743
				return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   744
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   745
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   746
		default:							
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   747
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   748
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   749
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   750
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   751
	if(!ParsePatchDllData())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   752
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   753
	if (iMissingFiles) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   754
		Print(EError, "Source Files Missing.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   755
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   756
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   757
	if (!iNumberOfFiles)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   758
		Print(EWarning,"No files specified.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   759
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   760
	return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   761
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   762
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   763
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   764
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   765
Process and stores the keyword information.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   766
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   767
@param aKeyword - keyword to update its value to variables.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   768
@return - Return the status i.e Success,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   769
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   770
TBool CObeyFile::ProcessDriveKeyword(enum EKeyword aKeyword) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   771
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   772
	TBool success = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   773
	switch (aKeyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   774
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   775
	case EKeywordDataImageName:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   776
		iDriveFileName = iReader.DupWord(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   777
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   778
	case EKeywordDataImageFileSystem:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   779
		iDriveFileFormat = iReader.DupWord(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   780
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   781
	case EKeywordDataImageSize:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   782
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   783
			const char* bigString = iReader.Word(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   784
			if(*bigString == '\0')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   785
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   786
				Print(EWarning,"Not a valid Image Size. Default size is considered\n");		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   787
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   788
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   789
 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   790
			Val(iConfigurableFatAttributes.iImageSize,bigString); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   791
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   792
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   793
	case EKeywordDataImageVolume:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   794
		{				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   795
			// Get the volume label provided by using "volume" keyword.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   796
			// e.g. vlolume = NO NAME
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   797
			string volumeLabel = iReader.GetCurrentObeyStatement();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   798
			string volumeLabelKeyword = "volume";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   799
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   800
			TUint position = volumeLabel.find(volumeLabelKeyword.c_str(),0,volumeLabelKeyword.size());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   801
			position += volumeLabelKeyword.size();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   802
			if (volumeLabel.find('=',position) != string::npos) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   803
				position=volumeLabel.find('=',position);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   804
				++position;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   805
			}								
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   806
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   807
			position = volumeLabel.find_first_not_of(' ',position);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   808
			if (position != string::npos) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   809
				volumeLabel = volumeLabel.substr(position);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   810
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   811
				// Remove the new line character from the end
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   812
				position = volumeLabel.find_first_of("\r\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   813
				if (position != string::npos)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   814
					volumeLabel = volumeLabel.substr(0,position);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   815
				size_t length = volumeLabel.length() ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   816
				if(length > 11) 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   817
						length = 11 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   818
				memcpy(iConfigurableFatAttributes.iDriveVolumeLabel,volumeLabel.c_str(),length) ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   819
				while(length != 11)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   820
					iConfigurableFatAttributes.iDriveVolumeLabel[length++] = ' ';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   821
				iConfigurableFatAttributes.iDriveVolumeLabel[length] = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   822
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   823
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   824
				Print(EWarning,"Value for Volume Label is not provided. Default value is considered.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   825
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   826
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   827
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   828
	case EKeywordDataImageSectorSize:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   829
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   830
			const char* bigString = iReader.Word(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   831
			TInt sectorSize = atoi(bigString);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   832
			if(sectorSize <= 0)	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   833
				Print(EWarning,"Invalid Sector Size value. Default value is considered.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   834
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   835
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   836
				iConfigurableFatAttributes.iDriveSectorSize = atoi(bigString);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   837
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   838
		}			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   839
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   840
	case EKeywordDataImageNoOfFats:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   841
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   842
			const char* bigString = iReader.Word(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   843
			TInt noOfFats = atoi(bigString);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   844
			if (noOfFats <=0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   845
				Print(EWarning,"Invalid No of FATs specified. Default value is considered.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   846
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   847
				iConfigurableFatAttributes.iDriveNoOfFATs = atoi(bigString);			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   848
		}			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   849
		break;			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   850
	default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   851
		// unexpected keyword iReader.Word(0), keep going.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   852
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   853
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   854
	return success;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   855
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   856
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   857
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   858
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   859
Checks whether obeyfile has supplied enough variables to continue.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   860
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   861
@return - Return the status 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   862
ETrue - Supplied valid values,
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   863
EFalse- Not valied values.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   864
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   865
TBool CObeyFile::GotKeyDriveVariables() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   866
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   867
	TBool retVal=ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   868
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   869
	// Mandatory keywords
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   870
	if (iDriveFileName==0) {                                                  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   871
		Print(EError,"The name of the image file has not been supplied.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   872
		Print(EError,"Use the keyword \"dataimagename\".\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   873
		retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   874
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   875
	// Check for '-'ve entered value.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   876
	if(iConfigurableFatAttributes.iImageSize <= 0){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   877
		Print(EWarning,"Image Size should be positive. Default size is Considered.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   878
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   879
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   880
	// File system format.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   881
	if(iDriveFileFormat==0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   882
		Print(EError,"The name of the file system not been supplied.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   883
		Print(EError,"Use the keyword \"dataimagefilesystem\".\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   884
		retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   885
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   886
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   887
	// Checking the validity of file system format.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   888
	if(iDriveFileFormat){		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   889
		if(stricmp(iDriveFileFormat,"FAT16") && stricmp(iDriveFileFormat,"FAT32")) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   890
			Print(EError,"The name of the file system not supported : %s\n",iDriveFileFormat);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   891
			retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   892
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   893
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   894
	if(retVal)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   895
		Print(ELog,"\nCreating Data Drive image : %s\n", iDriveFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   896
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   897
	return retVal;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   898
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   899
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   900
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   901
Process a parsed line to set up one or more new TRomBuilder entry objects.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   902
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   903
@param  - obey file keyword.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   904
// iWord[0] = the keyword (file,)      
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   905
// iWord[1] = the PC pathname
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   906
// iWord[2] = the EPOC pathname
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   907
// iWord[3] = start of the file attributes
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   908
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   909
@return - Return the status 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   910
ETrue - Successful generation of tree.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   911
EFalse- Fail to generate the tree.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   912
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   913
TBool CObeyFile::ProcessDriveFile(enum EKeyword aKeyword) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   914
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   915
	TBool isPeFile = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   916
	TBool aFileCompressOption, aFileUncompressOption;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   917
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   918
	TInt epocPathStart=2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   919
	aFileCompressOption = aFileUncompressOption = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   920
	// do some validation of the keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   921
	TInt currentLine = iReader.CurrentLine();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   922
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   923
	switch (aKeyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   924
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   925
	case EKeywordData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   926
	case EKeywordDir:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   927
	case EKeywordHide:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   928
		isPeFile = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   929
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   930
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   931
	case EKeywordFile:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   932
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   933
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   934
	case EKeywordFileCompress:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   935
		aFileCompressOption = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   936
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   937
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   938
	case EKeywordFileUncompress:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   939
		aFileUncompressOption = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   940
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   941
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   942
	default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   943
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   944
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   945
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   946
	if (aKeyword!=EKeywordHide && aKeyword!=EKeywordDir) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   947
		// check the PC file exists
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   948
		char* nname = NormaliseFileName(iReader.Word(1));		  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   949
		ifstream test(nname);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   950
		if(!test.is_open()){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   951
			Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   952
			iMissingFiles++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   953
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   954
		test.close();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   955
		delete []nname ;												
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   956
		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   957
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   958
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   959
		epocPathStart=1;   
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   960
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   961
	if(aKeyword != EKeywordDir)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   962
		iNumberOfFiles++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   963
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   964
	TBool endOfName=EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   965
	const char *epocStartPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   966
	if(aKeyword != EKeywordDir)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   967
		epocStartPtr = IsValidFilePath(iReader.Word(epocPathStart));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   968
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   969
		epocStartPtr = IsValidDirPath(iReader.Word(epocPathStart));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   970
	char *epocEndPtr = const_cast<char*>(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   971
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   972
	if (epocStartPtr == NULL) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   973
		Print(EError, "Invalid destination path on line %d\n",currentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   974
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   975
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   976
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   977
	TRomNode* dir=iRootDirectory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   978
	TRomNode* subDir=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   979
	TRomBuilderEntry *file=0;      
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   980
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   981
	while (!endOfName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   982
		endOfName = GetNextBitOfFileName(epocEndPtr);      
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   983
		if (endOfName && (aKeyword!=EKeywordDir)) { // file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   984
			TRomNode* alreadyExists=dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   985
			if ((aKeyword != EKeywordHide) && alreadyExists) { // duplicate file		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   986
				if (gKeepGoing) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   987
					Print(EWarning, "Duplicate file for %s on line %d, will be ignored\n",iReader.Word(1),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   988
					iNumberOfFiles--;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   989
					return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   990
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   991
				else {	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   992
					Print(EError, "Duplicate file for %s on line %d\n",iReader.Word(1),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   993
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   994
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   995
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   996
			else if((aKeyword == EKeywordHide) && (alreadyExists)) { 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   997
				alreadyExists->iEntry->iHidden = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   998
				alreadyExists->iHidden = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   999
				return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1000
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1001
			else if((aKeyword == EKeywordHide) && (!alreadyExists)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1002
				Print(EWarning, "Hiding non-existent file %s on line %d\n",iReader.Word(1),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1003
				return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1004
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1005
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1006
			file = new TRomBuilderEntry(iReader.Word(1), epocStartPtr);                   
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1007
			file->iExecutable=isPeFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1008
			if( aFileCompressOption ) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1009
				file->iCompressEnabled = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1010
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1011
			else if(aFileUncompressOption )	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1012
				file->iCompressEnabled = ECompressionUncompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1013
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1014
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1015
			TRomNode* node=new TRomNode(epocStartPtr, file);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1016
			if (node==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1017
				return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1018
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1019
			TInt r=ParseFileAttributes(node, file, aKeyword);         
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1020
			if (r!=KErrNone)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1021
				return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1022
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1023
			if(gCompress != ECompressionUnknown) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1024
				node->iFileUpdate = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1025
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1026
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1027
			if((node->iOverride) || (aFileCompressOption) || (aFileUncompressOption)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1028
				node->iFileUpdate = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1029
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1030
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1031
			dir->AddFile(node);	// to drive directory structure.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1032
		}		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1033
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1034
			// directory
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1035
			//for directory creation, given /sys/bin/, it's possible to reach 0 at the end, just ignore that...
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1036
			if(!*epocStartPtr)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1037
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1038
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1039
			subDir = dir->FindInDirectory(epocStartPtr);      
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1040
			if (!subDir){ // sub directory does not exist			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1041
				if(aKeyword==EKeywordHide) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1042
					Print(EWarning, "Hiding non-existent file %s on line %d\n",
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1043
						iReader.Word(1),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1044
					return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1045
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1046
				subDir = dir->NewSubDir(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1047
				if (!subDir)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1048
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1049
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1050
			dir=subDir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1051
			epocStartPtr = epocEndPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1052
		}  // end of else.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1053
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1054
	return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1055
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1056
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1057
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1058
TInt CObeyFile::SetStackSize(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1059
	if (EFalse == IsValidNumber(aStr))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1060
		return Print(EError, "Number required as argument for keyword 'stack'.\n"); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1061
	TInt size ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1062
	TInt err = Val(size,aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1063
	if(KErrNone == err){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1064
		aNode->SetStackSize(size );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1065
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1066
	return err;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1067
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1068
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1069
TInt CObeyFile::SetHeapSizeMin(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1070
	if (EFalse == IsValidNumber(aStr))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1071
		return Print(EError, "Number required as argument for keyword 'heapmin'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1072
	TInt size ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1073
	TInt err = Val(size,aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1074
	if(KErrNone == err){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1075
		aNode->SetHeapSizeMin(size );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1076
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1077
	return err;	 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1078
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1079
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1080
TInt CObeyFile::SetHeapSizeMax(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1081
	if (EFalse == IsValidNumber(aStr))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1082
		return Print(EError, "Number required as argument for keyword 'heapmax'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1083
	TInt size ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1084
	TInt err = Val(size,aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1085
	if(KErrNone == err){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1086
		aNode->SetHeapSizeMax(size );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1087
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1088
	return err;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1089
	 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1090
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1091
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1092
TInt CObeyFile::SetCapability(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1093
	if ( IsValidNumber(aStr)){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1094
		Print(EDiagnostic,"Old style numeric CAPABILTY specification ignored.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1095
		return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1096
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1097
	SCapabilitySet cap;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1098
	TInt r = ParseCapabilitiesArg(cap, (char*)aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1099
	if( KErrNone == r ) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1100
		aNode->SetCapability( cap );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1101
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1102
	return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1103
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1104
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1105
TInt CObeyFile::SetPriority(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1106
	TProcessPriority priority;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1107
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1108
	if ( IsValidNumber(aStr)) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1109
		TUint32 temp = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1110
		Val(temp,aStr) ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1111
		priority = (TProcessPriority)temp ; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1112
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1113
	else {	 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1114
		if (stricmp(aStr, "low")==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1115
			priority=EPriorityLow;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1116
		else if (strnicmp(aStr, "background", 4)==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1117
			priority=EPriorityBackground;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1118
		else if (strnicmp(aStr, "foreground", 4)==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1119
			priority=EPriorityForeground;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1120
		else if (stricmp(aStr, "high")==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1121
			priority=EPriorityHigh;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1122
		else if (strnicmp(aStr, "windowserver",3)==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1123
			priority=EPriorityWindowServer;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1124
		else if (strnicmp(aStr, "fileserver",4)==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1125
			priority=EPriorityFileServer;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1126
		else if (strnicmp(aStr, "realtimeserver",4)==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1127
			priority=EPriorityRealTimeServer;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1128
		else if (strnicmp(aStr, "supervisor",3)==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1129
			priority=EPrioritySupervisor;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1130
		else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1131
			return Print(EError, "Unrecognised priority keyword.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1132
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1133
	if (priority<EPriorityLow || priority>EPrioritySupervisor)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1134
		return Print(EError, "Priority out of range.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1135
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1136
	aNode->SetPriority( priority );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1137
	return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1138
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1139
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1140
TInt CObeyFile::SetUid1(TRomNode *aNode, const char* aStr){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1141
	if (EFalse == IsValidNumber(aStr))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1142
		return Print(EError, "Number required as argument for keyword 'uid1'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1143
	TInt size ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1144
	TInt err = Val(size,aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1145
	if(KErrNone == err){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1146
		aNode->SetUid1(size );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1147
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1148
	return err;		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1149
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1150
TInt CObeyFile::SetUid2(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1151
	if (EFalse == IsValidNumber(aStr))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1152
		return Print(EError, "Number required as argument for keyword 'uid2'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1153
	TInt size ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1154
	TInt err = Val(size,aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1155
	if(KErrNone == err){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1156
		aNode->SetUid2(size );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1157
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1158
	return err;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1159
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1160
TInt CObeyFile::SetUid3(TRomNode *aNode, const char* aStr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1161
	if (EFalse == IsValidNumber(aStr))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1162
		return Print(EError, "Number required as argument for keyword 'uid3'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1163
	TInt size ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1164
	TInt err = Val(size,aStr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1165
	if(KErrNone == err){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1166
		aNode->SetUid3(size );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1167
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1168
	return err;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1169
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1170
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1171
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1172
// Process any inline keywords
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1173
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1174
TInt CObeyFile::ParseFileAttributes(TRomNode *aNode, TRomBuilderEntry* aFile, enum EKeyword aKeyword) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1175
	TInt currentLine = iReader.CurrentLine();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1176
	enum EFileAttribute attribute;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1177
	TInt r=KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1178
	TInt index=3;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1179
	char* arg=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1180
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1181
	while(r==KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1182
		r=iReader.NextAttribute(index,(aFile!=0),attribute,arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1183
		if (r!=KErrNone)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1184
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1185
		switch(attribute)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1186
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1187
		case EAttributeAtt:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1188
			r=aNode->SetAtt(arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1189
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1190
		case EAttributeAttExtra:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1191
			r=aNode->SetAttExtra(arg, aFile, aKeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1192
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1193
		case EAttributeStack:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1194
			r=SetStackSize(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1195
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1196
		case EAttributeFixed:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1197
			aNode->SetFixed();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1198
			r = KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1199
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1200
		case EAttributeUid1:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1201
			r=SetUid1(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1202
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1203
		case EAttributeUid2:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1204
			r=SetUid2(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1205
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1206
		case EAttributeUid3:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1207
			r=SetUid3(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1208
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1209
		case EAttributeHeapMin:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1210
			r=SetHeapSizeMin(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1211
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1212
		case EAttributeHeapMax:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1213
			r=SetHeapSizeMax(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1214
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1215
		case EAttributePriority:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1216
			r=SetPriority(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1217
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1218
		case EAttributeCapability:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1219
			r=SetCapability(aNode, arg);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1220
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1221
		case EAttributeUnpaged:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1222
			aNode->iOverride |= KOverrideCodeUnpaged|KOverrideDataUnpaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1223
			aNode->iOverride &= ~(KOverrideCodePaged|KOverrideDataPaged);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1224
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1225
		case EAttributePaged:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1226
			aNode->iOverride |= KOverrideCodePaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1227
			aNode->iOverride &= ~(KOverrideCodeUnpaged);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1228
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1229
		case EAttributeUnpagedCode:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1230
			aNode->iOverride |= KOverrideCodeUnpaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1231
			aNode->iOverride &= ~KOverrideCodePaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1232
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1233
		case EAttributePagedCode:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1234
			aNode->iOverride |= KOverrideCodePaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1235
			aNode->iOverride &= ~KOverrideCodeUnpaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1236
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1237
		case EAttributeUnpagedData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1238
			aNode->iOverride |= KOverrideDataUnpaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1239
			aNode->iOverride &= ~KOverrideDataPaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1240
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1241
		case EAttributePagedData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1242
			aNode->iOverride |= KOverrideDataPaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1243
			aNode->iOverride &= ~KOverrideDataUnpaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1244
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1245
		default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1246
			return Print(EError, "Unrecognised keyword in file attributes on line %d.\n",currentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1247
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1248
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1249
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1250
	if (r==KErrEof)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1251
		return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1252
	return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1253
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1254
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1255
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1256
// Process a parsed line to set up one or more new TRomBuilder entry objects.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1257
// iWord[0] = the keyword (file, primary or secondary)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1258
// iWord[1] = the PC pathname
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1259
// iWord[2] = the EPOC pathname
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1260
// iWord[3] = start of the file attributes
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1261
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1262
TBool CObeyFile::ProcessFile(TInt /*aAlign*/, enum EKeyword aKeyword){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1263
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1264
	TBool isPeFile = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1265
	TBool aFileCompressOption, aFileUncompressOption;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1266
	TInt epocPathStart=2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1267
	aFileCompressOption = aFileUncompressOption = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1268
	TBool warnFlag = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1269
	static const char aStdPath[] = "SYS\\BIN\\";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1270
	static const int sysBinLength = sizeof(aStdPath)-1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1271
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1272
	// do some validation of the keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1273
	TInt currentLine = iReader.CurrentLine();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1274
	switch (aKeyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1275
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1276
	case EKeywordData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1277
	case EKeywordHideV2:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1278
		iNumberOfDataFiles++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1279
		isPeFile = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1280
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1281
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1282
	case EKeywordFile:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1283
		warnFlag = gEnableStdPathWarning;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1284
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1285
	case EKeywordFileCompress:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1286
		aFileCompressOption = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1287
		warnFlag = gEnableStdPathWarning;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1288
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1289
	case EKeywordFileUncompress:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1290
		aFileUncompressOption = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1291
		warnFlag = gEnableStdPathWarning;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1292
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1293
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1294
	default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1295
		Print(EError,"Unexpected keyword '%s' on line %d.\n",iReader.Word(0),currentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1296
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1297
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1298
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1299
	if (aKeyword!=EKeywordHideV2) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1300
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1301
		// check the PC file exists
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1302
		char* nname = NormaliseFileName(iReader.Word(1)); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1303
		ifstream test(nname);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1304
		if (!test) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1305
			Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1306
			iMissingFiles++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1307
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1308
		test.close();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1309
		delete []nname;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1310
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1311
	else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1312
		epocPathStart=1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1313
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1314
	iNumberOfFiles++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1315
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1316
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1317
	TBool endOfName=EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1318
	const char *epocStartPtr=IsValidFilePath(iReader.Word(epocPathStart));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1319
	char *epocEndPtr=const_cast<char*>(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1320
	if (epocStartPtr==NULL) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1321
		Print(EError, "Invalid destination path on line %d\n",currentLine);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1322
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1323
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1324
	if(warnFlag){	// Check for the std destination path(for executables) as per platsec.	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1325
		if(strnicmp(aStdPath,epocStartPtr,sysBinLength) != 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1326
			Print(EWarning,"Invalid destination path on line %d. \"%s\" \n",currentLine,epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1327
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1328
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1329
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1330
	TRomNode* dir=iRootDirectory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1331
	TRomNode* subDir=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1332
	TRomBuilderEntry *file=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1333
	while (!endOfName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1334
		endOfName = GetNextBitOfFileName(epocEndPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1335
		if (endOfName) {// file		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1336
			TRomNode* alreadyExists=dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1337
			/*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1338
			* The EKeywordHideV2 keyword is used to indicate that:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1339
			*	1. if the file exists in the same image and then hidden, mark it hidden
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1340
			*	2. if the file exists in another image, but in this (ROFS) image, it is
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1341
			*		required to hide that file, create a 0 length file entry setting the 'hide'
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1342
			*		flag so that at runtime, file gets hidden in the composite filesystem.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1343
			*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1344
			if ((aKeyword != EKeywordHideV2) && alreadyExists){ // duplicate file		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1345
				if(gKeepGoing){	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1346
					Print(EWarning, "Duplicate file for %s on line %d, will be ignored\n",iReader.Word(1),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1347
					switch (aKeyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1348
					{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1349
					case EKeywordData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1350
					case EKeywordHideV2:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1351
						iNumberOfDataFiles--;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1352
					default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1353
						break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1354
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1355
					iNumberOfFiles--;	 	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1356
					return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1357
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1358
				else {					
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1359
					Print(EError, "Duplicate file for %s on line %d\n",iReader.Word(1),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1360
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1361
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1362
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1363
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1364
			TBool aHidden = aKeyword==EKeywordHideV2;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1365
			/* The file is only marked hidden and hence the source file name isn't known 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1366
			* here as hide statement says :
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1367
			*	hide <filename as in ROM>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1368
			* Therefore, create TRomBuilderEntry with iFileName as 0 for hidden file when
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1369
			* the file doesn't exist in the same ROM image. Otherwise, the src file name
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1370
			* is known because of alreadyExists (which comes from the 'file'/'data' statement).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1371
			*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1372
			if(aHidden)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1373
				file = new TRomBuilderEntry(0, epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1374
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1375
				file = new TRomBuilderEntry(iReader.Word(1), epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1376
			file->iExecutable=isPeFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1377
			file->iHidden= aHidden;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1378
			if( aFileCompressOption ){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1379
				file->iCompressEnabled = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1380
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1381
			else if(aFileUncompressOption )	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1382
				file->iCompressEnabled = ECompressionUncompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1383
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1384
			TRomNode* node=new TRomNode(epocStartPtr, file);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1385
			if (node==0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1386
				return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1387
			TInt r=ParseFileAttributes(node, file, aKeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1388
			if (r!=KErrNone)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1389
				return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1390
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1391
			dir->AddFile(node);	// to ROFS directory structure
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1392
			AddFile(file);		// to our list of files
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1393
		}		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1394
		else { // directory		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1395
			subDir = dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1396
			if (!subDir) { // sub directory does not exist			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1397
				subDir = dir->NewSubDir(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1398
				if (!subDir)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1399
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1400
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1401
			dir=subDir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1402
			epocStartPtr = epocEndPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1403
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1404
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1405
	return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1406
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1407
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1408
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1409
TBool CObeyFile::ProcessRenaming(enum EKeyword aKeyword) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1410
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1411
	// find existing file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1412
	TBool endOfName=EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1413
	const char *epocStartPtr=IsValidFilePath(iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1414
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1415
	// Store the current name and new name to maintain renamed file map
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1416
	string currentName=iReader.Word(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1417
	string newName=iReader.Word(2);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1418
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1419
	char *epocEndPtr= const_cast<char*>(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1420
	if (epocStartPtr == NULL) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1421
		Print(EError, "Invalid source path on line %d\n",iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1422
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1423
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1424
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1425
	char saved_srcname[257];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1426
	strncpy(saved_srcname, iReader.Word(1),257);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1427
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1428
	TRomNode* dir=iRootDirectory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1429
	TRomNode* existingFile=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1430
	while (!endOfName){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1431
		endOfName = GetNextBitOfFileName(epocEndPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1432
		if (endOfName) { // file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1433
			existingFile=dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1434
			if (existingFile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1435
				TInt fileCount=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1436
				TInt dirCount=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1437
				existingFile->CountDirectory(fileCount, dirCount);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1438
				if (dirCount != 0 || fileCount != 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1439
					Print(EError, "Keyword %s not applicable to directories - line %d\n",
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1440
						iReader.Word(0),iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1441
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1442
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1443
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1444
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1445
		else { // directory		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1446
			TRomNode* subDir = dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1447
			if (!subDir) // sub directory does not exist
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1448
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1449
			dir=subDir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1450
			epocStartPtr = epocEndPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1451
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1452
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1453
	if (aKeyword == EKeywordHide) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1454
		/*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1455
		* The EKeywordHide keyword is used to indicate that if the file exists in 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1456
		* the primary ROFS image and then hidden in extension ROFS, mark it hidden.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1457
		*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1458
		if (!existingFile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1459
			Print(EWarning, "Hiding non-existent file %s on line %d\n", 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1460
				saved_srcname, iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1461
			// Just a warning, as we've achieved the right overall effect.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1462
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1463
		else if (existingFile->iFileStartOffset==(TUint)KFileHidden){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1464
			Print(EWarning, "Hiding already hidden file %s on line %d\n", 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1465
				saved_srcname, iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1466
			// We will igrore this request, otherwise it will "undelete" it.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1467
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1468
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1469
			//hidden files will not be placed to the image
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1470
			existingFile->iHidden = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1471
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1472
		return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1473
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1474
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1475
	if (!existingFile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1476
		Print(EError, "Can't %s non-existent source file %s on line %d\n",
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1477
			iReader.Word(0), saved_srcname, iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1478
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1479
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1480
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1481
	epocStartPtr = IsValidFilePath(iReader.Word(2));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1482
	epocEndPtr = const_cast<char*>(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1483
	endOfName = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1484
	if (epocStartPtr == NULL) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1485
		Print(EError, "Invalid destination path on line %d\n",iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1486
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1487
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1488
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1489
	TRomNode* newdir=iRootDirectory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1490
	while (!endOfName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1491
		endOfName = GetNextBitOfFileName(epocEndPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1492
		if (endOfName) {// file		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1493
			TRomNode* alreadyExists=newdir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1494
			if (alreadyExists && !(alreadyExists->iHidden)) {// duplicate file	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1495
				if(gKeepGoing){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1496
					Print(EWarning, "Duplicate file for %s on line %d, renaming will be skipped\n",saved_srcname,iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1497
					return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1498
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1499
				else {							
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1500
					Print(EError, "Duplicate file for %s on line %d\n",saved_srcname,iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1501
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1502
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1503
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1504
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1505
		else { // directory		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1506
			TRomNode* subDir = newdir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1507
			if (!subDir) {// sub directory does not exist			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1508
				subDir = newdir->NewSubDir(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1509
				if (!subDir)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1510
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1511
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1512
			newdir=subDir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1513
			epocStartPtr = epocEndPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1514
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1515
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1516
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1517
	if (aKeyword == EKeywordRename) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1518
		// rename => remove existingFile and insert into tree at new place
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1519
		// has no effect on the iNextExecutable or iNextNodeForSameFile links
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1520
		TInt r=ParseFileAttributes(existingFile, existingFile->iEntry, aKeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1521
		if (r!=KErrNone)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1522
			return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1523
		existingFile->Rename(dir, newdir, epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1524
		// Store the current and new name of file in the renamed file map.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1525
		iPatchData->AddToRenamedFileMap(currentName, newName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1526
		return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1527
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1528
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1529
	// alias => create new TRomNode entry and insert into tree
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1530
	TRomNode* node = new TRomNode(epocStartPtr, 0);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1531
	if (node == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1532
		Print(EError, "Out of memory\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1533
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1534
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1535
	node->Alias(existingFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1536
	TInt r=ParseFileAttributes(node, 0, aKeyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1537
	if (r!=KErrNone)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1538
		return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1539
	newdir->AddFile(node);	// to ROFS directory structure, though possibly hidden
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1540
	return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1541
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1542
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1543
TInt ParsePagingPolicy(const char* policy){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1544
	if(stricmp(policy,"NOPAGING") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1545
		return EKernelConfigPagingPolicyNoPaging;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1546
	else if (stricmp(policy,"ALWAYSPAGE") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1547
		return EKernelConfigPagingPolicyAlwaysPage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1548
	else if(stricmp(policy,"DEFAULTUNPAGED") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1549
		return EKernelConfigPagingPolicyDefaultUnpaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1550
	else if(stricmp(policy,"DEFAULTPAGED") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1551
		return EKernelConfigPagingPolicyDefaultPaged;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1552
	return KErrArgument;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1553
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1554
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1555
TBool CObeyFile::ProcessKeyword(enum EKeyword aKeyword) { 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1556
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1557
	TBool success = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1558
	switch (aKeyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1559
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1560
	case EKeywordRofsName:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1561
		iRomFileName = iReader.DupWord(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1562
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1563
	case EKeywordRofsSize:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1564
		Val(iRomSize,iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1565
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1566
	case EKeywordVersion:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1567
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1568
			istringstream val(iReader.Word(1)); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1569
			val >> iVersion;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1570
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1571
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1572
	case EKeywordRofsChecksum:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1573
		Val(iCheckSum,iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1574
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1575
	case EKeywordTime:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1576
		iReader.ProcessTime(iTime);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1577
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1578
	case EKeywordPagingOverride:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1579
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1580
			if(iPagingOverrideParsed)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1581
				Print(EWarning, "PagingOverride redefined - previous PagingOverride values lost\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1582
			if(iCodePagingOverrideParsed)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1583
				Print(EWarning, "PagingOverride defined - previous CodePagingOverride values lost\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1584
			iPagingOverrideParsed = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1585
			TInt policy = ParsePagingPolicy(iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1586
			if(policy < 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1587
				Print(EError,"Unrecognized option for PAGINGOVERRIDE keyword\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1588
				success = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1589
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1590
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1591
				gCodePagingOverride = policy;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1592
				if((policy == EKernelConfigPagingPolicyNoPaging) || (policy == EKernelConfigPagingPolicyDefaultUnpaged))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1593
					gDataPagingOverride = policy;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1594
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1595
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1596
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1597
	case EKeywordCodePagingOverride:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1598
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1599
			if(iCodePagingOverrideParsed)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1600
				Print(EWarning, "CodePagingOverride redefined - previous CodePagingOverride values lost\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1601
			if(iPagingOverrideParsed)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1602
				Print(EWarning, "CodePagingOverride defined - previous PagingOverride values lost\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1603
			iCodePagingOverrideParsed = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1604
			TInt policy = ParsePagingPolicy(iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1605
			if(policy<0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1606
			{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1607
				Print(EError,"Unrecognized option for CODEPAGINGOVERRIDE keyword\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1608
				success = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1609
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1610
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1611
				gCodePagingOverride = policy;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1612
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1613
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1614
	case EKeywordDataPagingOverride:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1615
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1616
			if(iDataPagingOverrideParsed)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1617
				Print(EWarning, "DataPagingOverride redefined - previous DataPagingOverride values lost\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1618
/*			if(iPagingOverrideParsed){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1619
				Print(EError, "DataPagingOverride defined - previous PagingOverride values lost\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1620
				success = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1621
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1622
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1623
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1624
			iDataPagingOverrideParsed = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1625
			TInt policy = ParsePagingPolicy(iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1626
			if(policy < 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1627
				Print(EError,"Unrecognized option for DATAPAGINGOVERRIDE keyword\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1628
				success = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1629
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1630
			else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1631
				gDataPagingOverride = policy;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1632
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1633
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1634
	case EKeywordRofsAutoSize:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1635
		iAutoSize = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1636
		Val(iAutoPageSize,iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1637
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1638
	default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1639
		// unexpected keyword iReader.Word(0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1640
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1641
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1642
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1643
	return success;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1644
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1645
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1646
// Checks that the obeyfile has supplied enough variables to continue
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1647
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1648
TBool CObeyFile::GotKeyVariables() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1649
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1650
	TBool retVal=ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1651
	// Mandatory keywords
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1652
	if (iRomFileName == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1653
		Print(EAlways,"The name of the image file has not been supplied.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1654
		Print(EAlways,"Use the keyword \"rofsname\".\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1655
		retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1656
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1657
	if (iRomSize == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1658
		Print(EAlways,"The size of the image has not been supplied.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1659
		Print(EAlways,"Use the keyword \"rofssize\".\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1660
		retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1661
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1662
	// Apply defaults as necessary
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1663
	if (iTime == 0)	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1664
		Print(ELog, "No timestamp specified. Using current time...\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1665
		ObeyFileReader::TimeNow(iTime);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1666
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1667
	Print(ELog, "\nCreating Rofs image %s\n", iRomFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1668
	return retVal;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1669
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1670
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1671
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1672
// Check the path is valid
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1673
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1674
const char* CObeyFile::IsValidFilePath(const char* aPath) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1675
	// skip leading "\"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1676
	if (*aPath == '/' || *aPath == '\\')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1677
		aPath++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1678
	if (*aPath == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1679
		return NULL; // file ends in a backslash
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1680
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1681
	const char *p = aPath;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1682
	TInt len=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1683
	while(*p) {			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1684
		if (*p == '/' || *p == '\\') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1685
			if (len == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1686
				return NULL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1687
			len=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1688
			p++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1689
			continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1690
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1691
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1692
		len++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1693
		p++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1694
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1695
	return (len ? aPath : NULL);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1696
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1697
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1698
const char* CObeyFile::IsValidDirPath(const char* aPath)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1699
{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1700
	const char* walker = aPath;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1701
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1702
	//validate path...
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1703
	while(*walker)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1704
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1705
		if(((*walker=='/') || (*walker=='\\')) && ((*(walker+1)=='/') || (*(walker+1)=='\\')))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1706
			return (const char*)0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1707
		walker++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1708
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1709
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1710
	if((*aPath=='/') || (*aPath=='\\'))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1711
		aPath++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1712
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1713
	return aPath;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1714
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1715
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1716
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1717
// Move the end pointer past the next directory separator, replacing it with 0
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1718
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1719
TBool CObeyFile::GetNextBitOfFileName(char*& epocEndPtr) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1720
	while (*epocEndPtr != '/' && *epocEndPtr != '\\'){ // until reach the directory separator		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1721
		if (*epocEndPtr == 0) // if reach end of string, return TRUE, it's the filename
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1722
			return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1723
		epocEndPtr++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1724
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1725
	*epocEndPtr = 0; // overwrite the directory separator with a 0
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1726
	epocEndPtr++; // point past the 0 ready for the next one
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1727
	return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1728
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1729
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1730
void CObeyFile::AddFile(TRomBuilderEntry* aFile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1731
	*iNextFilePtrPtr = aFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1732
	iNextFilePtrPtr = &(aFile->iNext);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1733
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1734
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1735
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1736
// First pass through the obey file to set up key variables
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1737
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1738
TInt CObeyFile::ProcessExtensionRofs(MRofsImage* aKernelRom) { 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1739
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1740
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1741
	enum EKeyword keyword;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1742
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1743
	// Deal with the "extensionrofs" keyword, which should be first
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1744
	// however, you may've found "time" before it.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1745
	while(iReader.NextLine(1,keyword) != KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1746
		if(EKeywordExtensionRofs == keyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1747
			break ;		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1748
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1749
	if(EKeywordExtensionRofs != keyword) return KErrEof;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1750
	iRomFileName = iReader.DupWord(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1751
	Print(ELog, "\n========================================================\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1752
	Print(ELog, "Extension ROFS %s starting at line %d\n\n", iRomFileName, iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1753
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1754
	iReader.MarkNext();		// so that we rewind to the line after the extensionrom keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1755
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1756
	while (iReader.NextLine(1,keyword) != KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1757
		if (keyword == EKeywordExtensionRofs)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1758
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1759
		ProcessExtensionKeyword(keyword);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1760
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1761
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1762
	if (!GotExtensionVariables(aKernelRom))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1763
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1764
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1765
	// second pass to process the file specifications in the obey file building
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1766
	// up the TRomNode directory structure and the TRomBuilderEntry list
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1767
	//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1768
	iReader.Rewind();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1769
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1770
	//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1771
	if (aKernelRom == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1772
		return Print(EError, "Option to extend a kernel ROFS image not yet implemented\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1773
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1774
	iRootDirectory = new TRomNode("");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1775
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1776
	iLastExecutable = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1777
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1778
	(aKernelRom->RootDirectory())->deleteTheFirstNode();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1779
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1780
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1781
	iRootDirectory = aKernelRom->CopyDirectory(iLastExecutable);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1782
	aKernelRom->SetRootDirectory(iRootDirectory);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1783
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1784
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1785
	TInt align=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1786
	while (iReader.NextLine(2,keyword)!=KErrEof) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1787
		if (keyword == EKeywordExtensionRofs)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1788
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1789
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1790
		switch (keyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1791
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1792
		case EKeywordHide:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1793
		case EKeywordAlias:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1794
		case EKeywordRename:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1795
			if (!ProcessRenaming(keyword))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1796
				return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1797
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1798
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1799
		case EKeywordPatchDllData:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1800
			{	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1801
				// Collect patchdata statements to process at the end
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1802
				StringVector patchDataTokens;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1803
				SplitPatchDataStatement(patchDataTokens); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1804
				iPatchData->AddPatchDataStatement(patchDataTokens);									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1805
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1806
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1807
		default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1808
			if (!ProcessFile(align, keyword))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1809
				return KErrGeneral;			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1810
			align=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1811
			break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1812
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1813
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1814
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1815
	if(!ParsePatchDllData() )
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1816
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1817
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1818
	iReader.MarkNext();			// ready for processing the next extension rom(s)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1819
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1820
	if (iMissingFiles!=0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1821
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1822
	if (iNumberOfFiles == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1823
		Print(EError, "No files specified.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1824
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1825
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1826
	return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1827
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1828
void CObeyFile::ProcessExtensionKeyword(enum EKeyword aKeyword)	{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1829
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1830
	switch (aKeyword)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1831
	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1832
	case EKeywordCoreRofsName:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1833
		iKernelRofsName = iReader.DupWord(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1834
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1835
	case EKeywordRofsSize:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1836
		Val(iRomSize,iReader.Word(1));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1837
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1838
	case EKeywordVersion:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1839
		{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1840
			istringstream val(iReader.Word(1)); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1841
			val >> iVersion;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1842
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1843
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1844
	case EKeywordRomChecksum:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1845
		Val(iCheckSum,iReader.Word(1)); //--
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1846
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1847
	case EKeywordTime:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1848
		iReader.ProcessTime(iTime);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1849
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1850
	case EKeywordRofsAutoSize:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1851
		iAutoSize = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1852
		Val(iAutoPageSize , iReader.Word(1)); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1853
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1854
	default:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1855
		Print(EError,"Keyword '%s' not valid in extension ROFS - line %d\n", iReader.Word(0), iReader.CurrentLine());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1856
		break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1857
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1858
	return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1859
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1860
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1861
// Checks that the obeyfile has supplied enough variables to continue
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1862
//
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1863
TBool CObeyFile::GotExtensionVariables(MRofsImage* aRom) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1864
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1865
	TBool retVal=ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1866
	const char* kernelRofsName = iKernelRofsName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1867
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1868
	// Mandatory keywords
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1869
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1870
	if (iRomSize == 0){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1871
		Print(EAlways,"The size of the extension ROFS has not been supplied.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1872
		Print(EAlways,"Use the keyword \"rofssize\".\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1873
		retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1874
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1875
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1876
	// keywords we need if we don't already have a ROFS image to work from
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1877
	if (aRom == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1878
		if (iKernelRofsName == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1879
			Print(EAlways,"The name of the core ROFS has not been supplied.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1880
			Print(EAlways,"Use the keyword \"rofsname\".\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1881
			retVal = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1882
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1883
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1884
	else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1885
		if (iKernelRofsName != 0){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1886
			Print(EWarning,"Keyword \"rofsname\" ignored.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1887
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1888
		kernelRofsName = aRom->RomFileName();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1889
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1890
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1891
	// validation
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1892
	// Apply defaults as necessary
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1893
	if (iTime == 0)	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1894
		Print(ELog, "No timestamp specified. Using current time...\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1895
		ObeyFileReader::TimeNow(iTime);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1896
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1897
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1898
	// fix up "*" in rofsname
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1899
	char newname[256];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1900
	char* p=newname;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1901
	char* q=iRomFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1902
	char c;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1903
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1904
	while ((c=*q++)!='\0'){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1905
		if (c!='*') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1906
			*p++=c;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1907
			continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1908
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1909
		const char *r = kernelRofsName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1910
		while ((c=*r++)!='\0')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1911
			*p++=c;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1912
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1913
	*p++ = '\0';
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1914
	delete []iRomFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1915
	size_t len = p - newname ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1916
	iRomFileName = new char[len];
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1917
	memcpy(iRomFileName,newname,len);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1918
	Print(ELog, "\nCreating ROFS image %s\n", iRomFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1919
	return retVal;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1920
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1921
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1922
// Fuction to split patchdata statement 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1923
void CObeyFile::SplitPatchDataStatement(StringVector& aPatchDataTokens) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1924
	// Get the value of symbol size, address/ordinal and new value 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1925
	// to be patched from the patchdata statement.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1926
	// Syntax of patchdata statements is as follows:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1927
	// 1)	patchdata dll_name  ordinal OrdinalNumber size_in_bytes   new_value 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1928
	// 2)   patchdata dll_name  addr    Address       size_in_bytes   new_value
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1929
	for(TInt count=1; count<=5; count++) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1930
		aPatchDataTokens.push_back(iReader.Word(count));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1931
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1932
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1933
	// Store the the value of current line which will be used
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1934
	// when displaying error messages.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1935
	ostringstream outStrStream;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1936
	outStrStream<<iReader.CurrentLine();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1937
	aPatchDataTokens.push_back(outStrStream.str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1938
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1939
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1940
TBool CObeyFile::ParsePatchDllData() {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1941
	// Get the list of patchdata statements
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1942
	VectorOfStringVector patchDataStatements=iPatchData->GetPatchDataStatements();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1943
	// Get the list of renamed file map
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1944
	MapOfString RenamedFileMap=iPatchData->GetRenamedFileMap();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1945
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1946
	for(TUint count=0; count < patchDataStatements.size(); count++) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1947
		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1948
		StringVector strVector = patchDataStatements.at(count);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1949
		string filename=strVector.at(0);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1950
		string lineNoStr = strVector.at(5);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1951
		TUint lineNo = 0 ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1952
		Val(lineNo,lineNoStr.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1953
		TRomNode* existingFile = NULL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1954
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1955
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1956
			TRomNode* dir=iRootDirectory;			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1957
			TBool endOfName=EFalse; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1958
			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1959
			if (!IsValidFilePath(filename.c_str())) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1960
				Print(EError, "Invalid source path on line %d\n",lineNo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1961
				return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1962
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1963
			char* epocStartPtr =NormaliseFileName(filename.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1964
			char* savedPtr = epocStartPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1965
			if(*epocStartPtr == '/' ||*epocStartPtr == '\\')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1966
				epocStartPtr++ ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1967
			char* epocEndPtr = epocStartPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1968
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1969
			while (!endOfName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1970
				endOfName = GetNextBitOfFileName(epocEndPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1971
				if (endOfName) {// file				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1972
					existingFile=dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1973
					if (existingFile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1974
						TInt fileCount=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1975
						TInt dirCount=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1976
						existingFile->CountDirectory(fileCount, dirCount);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1977
						if (dirCount != 0 || fileCount != 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1978
							Print(EError, "Keyword %s not applicable to directories - line %d\n","patchdata",lineNo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1979
							return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1980
						}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1981
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1982
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1983
				else {// directory				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1984
					TRomNode* subDir = dir->FindInDirectory(epocStartPtr);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1985
					if (!subDir) // sub directory does not exist
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1986
						break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1987
					dir=subDir;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1988
					epocStartPtr = epocEndPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1989
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1990
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1991
			delete []savedPtr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1992
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1993
			if(!existingFile) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1994
				// If the E32Image file to be patched is not included then check if the
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1995
				// file was renamed.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1996
				MapOfStringIterator RenamedFileMapIterator;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1997
				if ((RenamedFileMapIterator=RenamedFileMap.find(filename)) != RenamedFileMap.end())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1998
					filename = (*RenamedFileMapIterator).second; 				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  1999
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2000
					Print(EError, "File %s not found - line %d\n", filename.c_str(), lineNo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2001
					return EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2002
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2003
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2004
		}while(!existingFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2005
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2006
		TUint32 aSize, aOrdinal, aNewValue, aOffset;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2007
		TLinAddr aDataAddr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2008
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2009
		aOrdinal = (TUint32)-1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2010
		aDataAddr = (TUint32)-1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2011
		aOffset = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2012
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2013
		string symbolSize=strVector.at(3);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2014
		Val(aSize,symbolSize.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2015
		string aValue=strVector.at(4);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2016
		Val(aNewValue,aValue.c_str());		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2017
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2018
		DllDataEntry *dataEntry = new DllDataEntry(aSize, aNewValue);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2019
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2020
		// Set the address of the data or the ordinal number specified in OBY statement.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2021
		string keyword=strVector.at(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2022
		string keywordValue=strVector.at(2);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2023
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2024
		/* Check for +OFFSET at the end of the ordinal number or address */
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2025
		TUint plus = keywordValue.find("+",0);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2026
		if (plus != string::npos) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2027
			/* Get the offset that we found after the + sign */
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2028
			string offset = keywordValue.substr(plus+1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2029
			Val(aOffset,offset.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2030
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2031
			keywordValue.resize(plus);		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2032
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2033
		if(stricmp (keyword.c_str(), "addr") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2034
			Val(aDataAddr,keywordValue.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2035
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2036
		else 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2037
			Val(aOrdinal,keywordValue.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2038
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2039
		dataEntry->iDataAddress = aDataAddr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2040
		dataEntry->iOrdinal = aOrdinal;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2041
		dataEntry->iOffset = aOffset;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2042
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2043
		existingFile->SetDllData();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2044
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2045
		DllDataEntry *aDllDataEntry= existingFile->iEntry->GetFirstDllDataEntry();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2046
		if (aDllDataEntry == NULL) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2047
			// Set the first node of the patchdata linked list
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2048
			aDllDataEntry=dataEntry;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2049
			existingFile->iEntry->SetFirstDllDataEntry(aDllDataEntry);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2050
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2051
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2052
			// Goto the last node
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2053
			while((aDllDataEntry->NextDllDataEntry()) != NULL) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2054
				aDllDataEntry = aDllDataEntry->NextDllDataEntry();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2055
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2056
			// Add the new node at the end of linked list
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2057
			aDllDataEntry->AddDllDataEntry(dataEntry);			
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2058
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2059
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2060
	return ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
  2061
}