imgtools/romtools/rofsbuild/fatimagegenerator.cpp
author jjkang
Fri, 25 Jun 2010 20:58:33 +0800
changeset 605 122d2b873fd1
child 626 ac03b93ca9c4
permissions -rw-r--r--
Minor changes: rofsbuild
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     1
/*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     3
* All rights reserved.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     4
* This component and the accompanying materials are made available
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     6
* which accompanies this distribution, and is available
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     8
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     9
* Initial Contributors:
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    11
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    12
* Contributors:
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    13
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    14
* Description: 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    15
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    16
*/ 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    17
#include "fatimagegenerator.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    18
#include "fatcluster.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    19
#include "fsnode.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    20
#include "h_utl.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    21
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    22
#include <memory.h>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    23
#include <time.h>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    24
#include <iostream>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    25
#include <fstream>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    26
#include <iomanip>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    27
using namespace std;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    28
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    29
const TInt KCharsOfCmdWndLine = 80 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    30
const TInt KRootEntryCount = 0x200;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    31
const TInt KRootClusterIndex = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    32
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    33
TFatImgGenerator::TFatImgGenerator(TSupportedFatType aType ,ConfigurableFatAttributes& aAttr ) :
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    34
iType(aType),
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    35
iFatTable(0),
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    36
iFatTableBytes(0), 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    37
iTotalClusters(0),	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    38
iBytsPerClus(0)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    39
{
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    40
	memset(&iBootSector,0,sizeof(iBootSector));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    41
	memset(&iFat32Ext,0,sizeof(iFat32Ext));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    42
	memset(&iFatHeader,0,sizeof(iFatHeader));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    43
	if(aAttr.iDriveSectorSize != 512 && aAttr.iDriveSectorSize != 1024 && aAttr.iDriveSectorSize != 2048 && aAttr.iDriveSectorSize != 4096) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    44
		iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    45
		return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    46
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    47
	*((TUint32*)iBootSector.BS_jmpBoot) = 0x00905AEB ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    48
	memcpy(iBootSector.BS_OEMName,"SYMBIAN ",8);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    49
	*((TUint16 *)iBootSector.BPB_BytsPerSec) = aAttr.iDriveSectorSize;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    50
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    51
	iBootSector.BPB_NumFATs = aAttr.iDriveNoOfFATs;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    52
	iBootSector.BPB_Media = 0xF8 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    53
	iFatHeader.BS_DrvNum = 0x80 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    54
	iFatHeader.BS_BootSig = 0x29 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    55
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    56
	time_t rawtime;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    57
	time(&rawtime);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    58
	*((TUint32*)iFatHeader.BS_VolID) = (TUint32)rawtime;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    59
	memcpy(iFatHeader.BS_VolLab,aAttr.iDriveVolumeLabel,sizeof(iFatHeader.BS_VolLab));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    60
	if(aAttr.iImageSize == 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    61
		if(aType == EFat32)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    62
			aAttr.iImageSize = 0x100000000LL ;// 4G
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    63
		else
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    64
			aAttr.iImageSize = 0x40000000LL ; // 1G 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    65
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    66
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    67
	TUint32 totalSectors = (TUint32)((aAttr.iImageSize + aAttr.iDriveSectorSize - 1) / aAttr.iDriveSectorSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    68
	if(aType == EFat32) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    69
		InitAsFat32(totalSectors,aAttr.iSectorPerCluster ,aAttr.iDriveSectorSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    70
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    71
	else if(aType == EFat16) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    72
		InitAsFat16(totalSectors,aAttr.iSectorPerCluster,aAttr.iDriveSectorSize); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    73
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    74
	if(iType == EFatUnknown) return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    75
	iBytsPerClus = iBootSector.BPB_SecPerClus * aAttr.iDriveSectorSize;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    76
//	if(iBytsPerClus > KMaxClusterBytes){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    77
//		Print(EError,"Cluster too large!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    78
//		iType = EFatUnknown;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    79
//		return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    80
//	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    81
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    82
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    83
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    84
TFatImgGenerator::~TFatImgGenerator() {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    85
	if(iFatTable)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    86
		delete []iFatTable;  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    87
	Interator it = iDataClusters.begin();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    88
	while(it != iDataClusters.end()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    89
		TFatCluster* cluster = *it ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    90
		delete cluster;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    91
		it++;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    92
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    93
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    94
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    95
void TFatImgGenerator::InitAsFat16(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    96
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    97
	TUint32 numOfClusters ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    98
	if(aSecPerClus == 0) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    99
		//Auto-calc the SecPerClus
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   100
		// FAT32 ,Count of clusters must >= 4085 and < 65525 , however , to avoid the "off by xx" warning, 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   101
		// proprositional value >= (4085 + 16) && < (65525 - 16)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   102
		if(aTotalSectors < (4085 + 16)) { //when SecPerClus is 1, numOfClusters eq to aTotalSectors
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   103
			iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   104
			Print(EError,"Size is too small for FAT16, please set a bigger size !\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   105
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   106
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   107
		TUint8 secPerClusMax = KMaxClusterBytes / aBytsPerSec; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   108
		numOfClusters = (aTotalSectors + secPerClusMax - 1) / secPerClusMax ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   109
		if(numOfClusters >= (65525 - 16)) { // too big 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   110
			iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   111
			Print(EError,"Size is too big for FAT16, please use the FAT32 format!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   112
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   113
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   114
		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   115
		aSecPerClus = 1;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   116
		while(aSecPerClus < secPerClusMax){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   117
			numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   118
			if (numOfClusters >= (4085 + 16) && numOfClusters < (65525 - 16)) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   119
				break;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   120
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   121
			aSecPerClus <<= 1 ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   122
		}	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   123
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   124
	else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   125
		if( (aSecPerClus * aBytsPerSec) > KMaxClusterBytes){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   126
			Print(EError,"Cluster too large!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   127
			iType = EFatUnknown;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   128
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   129
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   130
		numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   131
		if(numOfClusters >= (65525 - 16)){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   132
      Print(EError,"Cluster count is too big for FAT16, please use the FAT32 format or set a new bigger sector count of cluster!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   133
			iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   134
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   135
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   136
		else if(numOfClusters < (4085 + 16)){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   137
      Print(EError,"Cluster count is too small for FAT16, please set a new small sector count of cluster or set the size bigger!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   138
			iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   139
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   140
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   141
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   142
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   143
	iTotalClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   144
	iFatTableBytes = ((iTotalClusters << 1) +  aBytsPerSec - 1) & (~(aBytsPerSec - 1)); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   145
	iFatTable = new(std::nothrow) char[iFatTableBytes];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   146
	if(!iFatTable) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   147
        Print(EError,"Memory allocation failed for FAT16 Table!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   148
		iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   149
		return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   150
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   151
	memset(iFatTable,0,iFatTableBytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   152
	*((TUint32*)iFatTable) = 0xFFFFFFF8 ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   153
	iBootSector.BPB_SecPerClus = aSecPerClus;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   154
	*((TUint16*)iBootSector.BPB_RsvdSecCnt) = 0x0001 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   155
	*((TUint16*)iBootSector.BPB_RootEntCnt) = KRootEntryCount ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   156
	if(aTotalSectors > 0xFFFF)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   157
		*((TUint32*)iBootSector.BPB_TotSec32) = aTotalSectors; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   158
	else
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   159
		*((TUint16*)iBootSector.BPB_TotSec16) = (TUint16)aTotalSectors; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   160
	TUint16 sectorsForFAT = (TUint16)((iFatTableBytes + aBytsPerSec - 1) / aBytsPerSec);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   161
	*((TUint16*)iBootSector.BPB_FATSz16) =  sectorsForFAT ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   162
	memcpy(iFatHeader.BS_FilSysType,"FAT16   ",sizeof(iFatHeader.BS_FilSysType));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   163
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   164
void TFatImgGenerator::InitAsFat32(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec) { 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   165
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   166
	TUint32 numOfClusters;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   167
	if(aSecPerClus == 0) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   168
		//Auto-calc the SecPerClus
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   169
		// FAT32 ,Count of clusters must >= 65525, however , to avoid the "off by xx" warning, 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   170
		// proprositional value >= (65525 + 16)			
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   171
		if(aTotalSectors < (65525 + 16)) { //when SecPerClus is 1, numOfClusters eq to aTotalSectors
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   172
			iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   173
			Print(EError,"Size is too small for FAT32, please use the FAT16 format, or set the data size bigger!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   174
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   175
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   176
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   177
		TUint8 secPerClusMax = KMaxClusterBytes / aBytsPerSec; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   178
		aSecPerClus = secPerClusMax;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   179
		while(aSecPerClus > 1){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   180
			numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   181
			if (numOfClusters >= (65525 + 16)) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   182
				break;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   183
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   184
			aSecPerClus >>= 1 ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   185
		}	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   186
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   187
	else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   188
		if( (aSecPerClus * aBytsPerSec) > KMaxClusterBytes){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   189
			Print(EError,"Cluster too large!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   190
			iType = EFatUnknown;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   191
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   192
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   193
		numOfClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   194
		if(numOfClusters < (65525 + 16)) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   195
            Print(EError,"Cluster count is too small for FAT32, please set a new small sector count of cluster or set the size bigger or use the FAT16 format!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   196
			iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   197
			return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   198
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   199
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   200
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   201
	iTotalClusters = (aTotalSectors + aSecPerClus - 1) / aSecPerClus ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   202
	iFatTableBytes = ((iTotalClusters << 2) +  aBytsPerSec - 1) & (~(aBytsPerSec - 1));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   203
	iFatTable = new(std::nothrow) char[iFatTableBytes];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   204
	if(!iFatTable) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   205
        Print(EError,"Memory allocation failed for FAT32 Table!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   206
		iType = EFatUnknown ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   207
		return ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   208
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   209
	memset(iFatTable,0,iFatTableBytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   210
	TUint32* fat32table = reinterpret_cast<TUint32*>(iFatTable);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   211
	fat32table[0] = 0x0FFFFFF8 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   212
	fat32table[1] = 0x0FFFFFFF ;  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   213
	iBootSector.BPB_SecPerClus = aSecPerClus;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   214
	iBootSector.BPB_RsvdSecCnt[0] = 0x20 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   215
	*((TUint32*)iBootSector.BPB_TotSec32) = aTotalSectors; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   216
	*((TUint32*)iFat32Ext.BPB_FATSz32) =  (iFatTableBytes + aBytsPerSec - 1) / aBytsPerSec; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   217
	*((TUint32*)iFat32Ext.BPB_RootClus) = 2 ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   218
	*((TUint16*)iFat32Ext.BPB_FSInfo) = 1 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   219
	*((TUint16*)iFat32Ext.BPB_BkBootSec) = 6 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   220
	memcpy(iFatHeader.BS_FilSysType,"FAT32   ",sizeof(iFatHeader.BS_FilSysType));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   221
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   222
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   223
bool TFatImgGenerator::Execute(TFSNode* aRootDir , const char* aOutputFile){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   224
	if(EFatUnknown == iType)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   225
		return false ;	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   226
	ofstream o(aOutputFile,ios_base::binary + ios_base::out + ios_base::trunc);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   227
	TUint32 writtenBytes = 0 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   228
	if(!o.is_open()) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   229
  	Print(EError,"Can not open \"%s\" for writing !\n",aOutputFile) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   230
		return false;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   231
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   232
	TUint16 bytsPerSector = *((TUint16*)iBootSector.BPB_BytsPerSec);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   233
	Interator it = iDataClusters.begin();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   234
	while(it != iDataClusters.end()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   235
		TFatCluster* cluster = *it ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   236
		delete cluster;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   237
		it++;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   238
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   239
	iDataClusters.clear();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   240
	Print(EAlways,"Filesystem ready.\nWriting Header...");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   241
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   242
	if(EFat16 == iType){		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   243
		char* header = new(std::nothrow) char[bytsPerSector];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   244
		if(!header){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   245
      Print(EError,"Can not allocate memory for FAT16 header!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   246
			o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   247
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   248
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   249
		int offset = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   250
		memcpy(header,&iBootSector,sizeof(iBootSector));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   251
		offset = sizeof(iBootSector);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   252
		memcpy(&header[offset],&iFatHeader,sizeof(iFatHeader));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   253
		offset += sizeof(iFatHeader);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   254
		memset(&header[offset],0,bytsPerSector - offset);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   255
		*((TUint16*)(&header[510])) = 0xAA55 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   256
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   257
		o.write(header,bytsPerSector); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   258
		writtenBytes +=  bytsPerSector;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   259
		delete []header ;		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   260
		TUint16 rootDirSectors = (KRootEntryCount * 32) / bytsPerSector ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   261
		TUint16 rootDirClusters = (rootDirSectors + iBootSector.BPB_SecPerClus - 1) /iBootSector.BPB_SecPerClus;		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   262
		TUint32 rootDirBytes = KRootEntryCount * 32;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   263
		TFatCluster* rootDir = new(std::nothrow) TFatCluster(0,rootDirClusters);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   264
		rootDir->Init(rootDirBytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   265
		iDataClusters.push_back(rootDir);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   266
		aRootDir->WriteDirEntries(KRootClusterIndex,rootDir->GetData());
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   267
		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   268
		TUint index = 2 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   269
		Print(EAlways,"    OK.\nPreparing cluster list..."); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   270
		TFSNode* child = aRootDir->GetFirstChild() ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   271
		while(child){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   272
			if(!PrepareClusters(index,child)){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   273
                Print(EAlways,"    Failed.\nError:Image size is expected to be big enough for all the files.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   274
				return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   275
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   276
			child = child->GetSibling() ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   277
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   278
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   279
	else if(EFat32 == iType){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   280
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   281
		TUint headerSize = ( bytsPerSector << 5 ); // 32 reserved sectors for fat32
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   282
		char* header = new(std::nothrow) char[headerSize];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   283
		if(!header){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   284
            Print(EError,"Can not allocate memory for FAT32 header!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   285
			o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   286
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   287
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   288
		memset(header,0,headerSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   289
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   290
		int offset = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   291
		memcpy(header,&iBootSector,sizeof(iBootSector));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   292
		offset = sizeof(iBootSector);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   293
		memcpy(&header[offset],&iFat32Ext,sizeof(iFat32Ext));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   294
		offset += sizeof(iFat32Ext);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   295
		memcpy(&header[offset],&iFatHeader,sizeof(iFatHeader));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   296
		offset += sizeof(iFatHeader);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   297
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   298
		TFAT32FSInfoSector* fsinfo = reinterpret_cast<TFAT32FSInfoSector*>(&header[bytsPerSector]);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   299
		*((TUint32*)fsinfo->FSI_LeadSig) = 0x41615252 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   300
		*((TUint32*)fsinfo->FSI_StrucSig) = 0x61417272 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   301
		memset(fsinfo->FSI_Free_Count,0xFF,8);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   302
		char* tailed = header + 510 ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   303
		for(int i = 0 ; i < 32 ; i++ , tailed += bytsPerSector )
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   304
			*((TUint16*)tailed) = 0xAA55 ;		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   305
		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   306
		TUint index = 2 ;		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   307
		Print(EAlways,"    OK.\nPreparing cluster list...");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   308
		if(!PrepareClusters(index,aRootDir)) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   309
            Print(EAlways,"    Failed.\nERROR: Image size is expected to be big enough for all the files.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   310
			delete []header ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   311
			return false;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   312
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   313
	 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   314
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   315
		*(TUint32*)(fsinfo->FSI_Free_Count) = iTotalClusters - index + 3;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   316
		*(TUint32*)(fsinfo->FSI_Nxt_Free) =  index ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   317
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   318
		// write bakup boot sectors
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   319
		memcpy(&header[bytsPerSector * 6],header,(bytsPerSector << 1));
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   320
		o.write(header,headerSize); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   321
		writtenBytes += headerSize;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   322
		delete []header ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   323
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   324
	//iDataClusters.sort();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   325
	it = iDataClusters.end() ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   326
	it -- ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   327
	int clusters = (*it)->GetIndex() + (*it)->ActualClusterCount() - 1;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   328
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   329
	Print(EAlways,"    OK.\n%d clusters of data need to be written.\nWriting Fat table...",clusters);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   330
	for(TUint8 w = 0 ; w < iBootSector.BPB_NumFATs ; w++){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   331
		o.write(iFatTable,iFatTableBytes);	 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   332
		if(o.bad() || o.fail()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   333
			Print(EAlways,"\nERROR:Writting failed. Please check the filesystem\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   334
			delete []iFatTable,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   335
			o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   336
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   337
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   338
		writtenBytes += iFatTableBytes;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   339
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   340
	char* buffer = new(std::nothrow) char[KBufferedIOBytes];
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   341
	if(!buffer){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   342
    Print(EError,"Can not allocate memory for I/O buffer !\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   343
		o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   344
		return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   345
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   346
	o.flush();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   347
	Print(EAlways,"    OK.\nWriting clusters data...");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   348
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   349
	int bytesInBuffer = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   350
	int writeTimes = 24; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   351
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   352
	TFatCluster* lastClust = 0 ;	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   353
	for(it = iDataClusters.begin(); it != iDataClusters.end() ; it++ ){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   354
		TFatCluster* cluster = *it ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   355
		TUint fileSize = cluster->GetSize(); 		 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   356
		TUint toProcess = cluster->ActualClusterCount() * iBytsPerClus ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   357
		if(toProcess > KBufferedIOBytes){ // big file 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   358
			if(bytesInBuffer > 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   359
				o.write(buffer,bytesInBuffer); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   360
				if(o.bad() || o.fail()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   361
					Print(EError,"Writting failed.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   362
					delete []buffer,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   363
					o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   364
					return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   365
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   366
				writtenBytes += bytesInBuffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   367
				bytesInBuffer = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   368
				Print(EAlways,".");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   369
				writeTimes ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   370
				if((writeTimes % KCharsOfCmdWndLine) == 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   371
					o.flush();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   372
					cout << endl ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   373
				} 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   374
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   375
			if(cluster->IsLazy()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   376
				ifstream ifs(cluster->GetFileName(), ios_base::binary + ios_base::in);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   377
				if(!ifs.is_open()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   378
					Print(EError,"Can not open file \"%s\"\n",cluster->GetFileName()) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   379
					o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   380
					delete []buffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   381
					return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   382
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   383
				if(!ifs.good()) ifs.clear(); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   384
				TUint processedBytes = 0 ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   385
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   386
				while(processedBytes < 	fileSize){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   387
					TUint ioBytes = fileSize - processedBytes ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   388
					if(ioBytes > KBufferedIOBytes)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   389
						ioBytes = KBufferedIOBytes;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   390
					ifs.read(buffer,ioBytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   391
					processedBytes += ioBytes;					 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   392
					o.write(buffer,ioBytes); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   393
					if(o.bad() || o.fail()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   394
						Print(EError,"Writting failed.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   395
						delete []iFatTable,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   396
						o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   397
						return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   398
					}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   399
					writtenBytes += ioBytes;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   400
					Print(EAlways,".");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   401
					writeTimes ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   402
					if((writeTimes % KCharsOfCmdWndLine) == 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   403
						o.flush();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   404
						Print(EAlways,"\n") ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   405
					}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   406
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   407
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   408
				TUint paddingBytes = toProcess - processedBytes;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   409
				if( paddingBytes > 0 ){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   410
					memset(buffer,0,paddingBytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   411
					o.write(buffer,paddingBytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   412
					if(o.bad() || o.fail()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   413
						Print(EError,"Writting failed.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   414
						delete []buffer,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   415
						o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   416
						return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   417
					}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   418
					writtenBytes += paddingBytes;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   419
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   420
				ifs.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   421
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   422
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   423
			else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   424
				// impossible 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   425
        Print(EError,"Unexpected result!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   426
				o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   427
				delete []buffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   428
				return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   429
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   430
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   431
		else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   432
			if(toProcess > (KBufferedIOBytes - bytesInBuffer)){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   433
				o.write(buffer,bytesInBuffer); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   434
				if(o.bad() || o.fail()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   435
					Print(EError,"Writting failed.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   436
					delete []buffer,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   437
					o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   438
					return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   439
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   440
				writtenBytes += bytesInBuffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   441
				Print(EAlways,".");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   442
				writeTimes ++ ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   443
				if((writeTimes % KCharsOfCmdWndLine) == 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   444
					o.flush();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   445
					cout  << endl ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   446
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   447
				bytesInBuffer = 0;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   448
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   449
			if(cluster->IsLazy()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   450
				ifstream ifs(cluster->GetFileName(), ios_base::binary + ios_base::in);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   451
				if(!ifs.is_open()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   452
				    Print(EError,"Can not open file \"%s\"\n",cluster->GetFileName()) ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   453
					o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   454
					delete []buffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   455
					return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   456
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   457
				if(!ifs.good()) ifs.clear(); 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   458
				ifs.read(&buffer[bytesInBuffer],fileSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   459
				bytesInBuffer += fileSize;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   460
				if(toProcess > fileSize) { // fill padding bytes 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   461
					memset(&buffer[bytesInBuffer],0,toProcess - fileSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   462
					bytesInBuffer += (toProcess - fileSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   463
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   464
				ifs.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   465
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   466
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   467
			else{
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   468
				if(toProcess != cluster->GetSize() && cluster->GetIndex() != KRootClusterIndex){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   469
        	Print(EError,"Unexpected size!\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   470
					o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   471
					delete []buffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   472
					return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   473
				}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   474
				memcpy(&buffer[bytesInBuffer],cluster->GetData(),cluster->GetSize());
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   475
				bytesInBuffer += cluster->GetSize();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   476
			}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   477
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   478
		} 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   479
		lastClust = cluster ;	 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   480
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   481
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   482
	if(bytesInBuffer > 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   483
		o.write(buffer,bytesInBuffer);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   484
		if(o.bad() || o.fail()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   485
			Print(EError,"Writting failed.\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   486
			delete []buffer,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   487
			o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   488
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   489
		}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   490
		writtenBytes += bytesInBuffer;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   491
		o.flush();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   492
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   493
	Print(EAlways,"\nDone.\n\n");
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   494
	o.close();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   495
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   496
	return true ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   497
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   498
bool TFatImgGenerator::PrepareClusters(TUint& aNextClusIndex,TFSNode* aNode) { 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   499
	TUint sizeOfItem = aNode->GetSize();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   500
	TUint clusters = (sizeOfItem + iBytsPerClus - 1) / iBytsPerClus;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   501
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   502
	if(iTotalClusters < aNextClusIndex + clusters)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   503
		return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   504
		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   505
	TUint16* fat16Table = reinterpret_cast<TUint16*>(iFatTable);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   506
	TUint32* fat32Table = reinterpret_cast<TUint32*>(iFatTable);	 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   507
	 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   508
	for(TUint i = aNextClusIndex + clusters - 1 ; i > aNextClusIndex  ; i--){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   509
		if(iType == EFat16)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   510
			fat16Table[i - 1] = i ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   511
		else
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   512
			fat32Table[i - 1] = i ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   513
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   514
	if(iType == EFat16)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   515
		fat16Table[aNextClusIndex + clusters - 1] = 0xffff ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   516
	else
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   517
		fat32Table[aNextClusIndex + clusters - 1] = 0x0fffffff ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   518
		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   519
	TFatCluster* cluster = new TFatCluster(aNextClusIndex,clusters);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   520
	if(aNode->IsDirectory()) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   521
    TUint bytes = clusters * iBytsPerClus ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   522
		cluster->Init(bytes);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   523
		aNode->WriteDirEntries(aNextClusIndex,cluster->GetData());
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   524
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   525
	else {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   526
		cluster->LazyInit(aNode->GetPCSideName(),sizeOfItem);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   527
		aNode->WriteDirEntries(aNextClusIndex,NULL);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   528
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   529
	iDataClusters.push_back(cluster);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   530
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   531
	aNextClusIndex += clusters;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   532
	if(aNode->GetFirstChild()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   533
		if(!PrepareClusters(aNextClusIndex,aNode->GetFirstChild()))
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   534
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   535
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   536
	if(aNode->GetSibling()){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   537
		if(!PrepareClusters(aNextClusIndex,aNode->GetSibling()))
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   538
			return false;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   539
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   540
	return true ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
   541
}