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