imgtools/romtools/rofsbuild/fatcluster.cpp
author lorewang
Mon, 22 Nov 2010 10:41:57 +0800
changeset 699 9ca650050cf0
parent 605 122d2b873fd1
permissions -rw-r--r--
ou1cimx1#656196 one line message of ROM tools
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 "fatcluster.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    18
#include <string.h> 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    19
#include <iostream>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    20
#include <new>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    21
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    22
TFatCluster::TFatCluster(int aIndex,int aActClustCnt/* = 1*/) :iIndex(aIndex), iActualClusterCount(aActClustCnt), 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    23
iSize(0) ,iData(0),iFileName(0),iLazy(true){  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    24
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    25
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    26
TFatCluster::~TFatCluster() {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    27
	if(iData) 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    28
		delete []iData ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    29
	if(iFileName)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    30
		delete []iFileName;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    31
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    32
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    33
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    34
bool TFatCluster::Init(TUint aSize) {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    35
	if(iData == 0){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    36
		iData = reinterpret_cast<TUint8*>(new(std::nothrow) char[aSize]);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    37
		if(iData == 0)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    38
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    39
		memset(iData,0,aSize);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    40
		iSize = aSize ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    41
		iLazy = false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    42
		return true ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    43
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    44
	return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    45
}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    46
bool TFatCluster::LazyInit(const char* aFileName,TUint aFileSize){
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    47
	if(iFileName == 0){		
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    48
		int len = strlen(aFileName) + 1;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    49
		iFileName = new(std::nothrow) char[len] ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    50
		if(iFileName == 0)
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    51
			return false ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    52
		iLazy = true ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    53
		memcpy(iFileName,aFileName,len);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    54
		iSize = aFileSize ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    55
	}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    56
	return false;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    57
}