605
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "fatcluster.h"
|
|
18 |
#include <string.h>
|
|
19 |
#include <iostream>
|
|
20 |
#include <new>
|
|
21 |
|
|
22 |
TFatCluster::TFatCluster(int aIndex,int aActClustCnt/* = 1*/) :iIndex(aIndex), iActualClusterCount(aActClustCnt),
|
|
23 |
iSize(0) ,iData(0),iFileName(0),iLazy(true){
|
|
24 |
}
|
|
25 |
|
|
26 |
TFatCluster::~TFatCluster() {
|
|
27 |
if(iData)
|
|
28 |
delete []iData ;
|
|
29 |
if(iFileName)
|
|
30 |
delete []iFileName;
|
|
31 |
}
|
|
32 |
|
|
33 |
|
|
34 |
bool TFatCluster::Init(TUint aSize) {
|
|
35 |
if(iData == 0){
|
|
36 |
iData = reinterpret_cast<TUint8*>(new(std::nothrow) char[aSize]);
|
|
37 |
if(iData == 0)
|
|
38 |
return false ;
|
|
39 |
memset(iData,0,aSize);
|
|
40 |
iSize = aSize ;
|
|
41 |
iLazy = false ;
|
|
42 |
return true ;
|
|
43 |
}
|
|
44 |
return false ;
|
|
45 |
}
|
|
46 |
bool TFatCluster::LazyInit(const char* aFileName,TUint aFileSize){
|
|
47 |
if(iFileName == 0){
|
|
48 |
int len = strlen(aFileName) + 1;
|
|
49 |
iFileName = new(std::nothrow) char[len] ;
|
|
50 |
if(iFileName == 0)
|
|
51 |
return false ;
|
|
52 |
iLazy = true ;
|
|
53 |
memcpy(iFileName,aFileName,len);
|
|
54 |
iSize = aFileSize ;
|
|
55 |
}
|
|
56 |
return false;
|
|
57 |
}
|