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