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