|
1 /* |
|
2 * Copyright (c) 2006-2009 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 * CDIRREGION.H |
|
16 * Directory Region Operations for FileSystem component |
|
17 * @internalComponent |
|
18 * @released |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 #ifndef DIRREGION_H |
|
24 #define DIRREGION_H |
|
25 |
|
26 #include "filesystemclass.h" |
|
27 #include "longname.h" |
|
28 |
|
29 #include <fstream> |
|
30 #include <map> |
|
31 #include <string> |
|
32 |
|
33 class CFileSystem; |
|
34 |
|
35 typedef std::ofstream OfStream; |
|
36 typedef std::ifstream IfStream; |
|
37 typedef std::ios Ios; |
|
38 typedef std::map<unsigned int,std::string> StringMap; |
|
39 |
|
40 /** |
|
41 This class describes the member functions and data members required to create directory/data |
|
42 region of FAT image. |
|
43 |
|
44 @internalComponent |
|
45 @released |
|
46 */ |
|
47 |
|
48 class CDirRegion |
|
49 { |
|
50 private: |
|
51 void FormatName(String& aString,char aAttrValue); |
|
52 unsigned int Get32BitClusterNumber(unsigned int aHighWord, unsigned int aLowWord); |
|
53 void CheckEntry(EntryList aNodeList); |
|
54 void CreateDirEntry(CDirectory* aEntry,unsigned int aParentDirClusterNumber); |
|
55 void CreateAndWriteCurrentDirEntry(unsigned int aCurClusterNumber,String& aString); |
|
56 void CreateAndWriteParentDirEntry(unsigned int aParDirClusterNumber,String& aString); |
|
57 void WriteEntryToString(CDirectory* aEntry,String& aString); |
|
58 bool IsLongEntry(CDirectory* aEntry) const; |
|
59 void CreateLongEntries(CDirectory* aEntry,String& aDirString); |
|
60 void WriteFileDataInToCluster(CDirectory* aEntry); |
|
61 void PushStringIntoClusterMap(unsigned int aNumber, |
|
62 String& aDirString, |
|
63 unsigned long int aClusterSize, |
|
64 char aAttribute); |
|
65 void PushDirectoryEntryString(unsigned int aNumber,String& aString,int aClustersRequired); |
|
66 |
|
67 public: |
|
68 CDirRegion( EntryList iNodeList, |
|
69 CFileSystem *aFileSystemPtr); |
|
70 ~CDirRegion(); |
|
71 void Execute(); |
|
72 void WriteClustersIntoFile(OfStream& aOutPutStream); |
|
73 TClustersPerEntryMap* GetClustersPerEntryMap() const; |
|
74 |
|
75 private: |
|
76 IfStream iInputStream; //Input stream, used to read file contents |
|
77 CCluster* iClusterPtr; //pointer to class CCluster |
|
78 bool iCurrentDirEntry; //Is current entry(.) is created? |
|
79 bool iParentDirEntry;//Is parent entry (..) is created? |
|
80 bool iFirstCluster; //Is this the first cluster for the current FAT image? |
|
81 |
|
82 unsigned int iCurEntryClusterNumber; //Holds current entries cluster number |
|
83 unsigned int iClusterKey; //Number used to map cluster with cluster contents |
|
84 /* To avoid calling CCluster::GetClusterSize() function multiple times, this |
|
85 *variable introduced. |
|
86 */ |
|
87 unsigned long int iClusterSize; |
|
88 |
|
89 StringMap iClusterMap; //The map between cluster number and cluster |
|
90 unsigned int iRootDirSizeInBytes;//Reserved sectors for root directory entry |
|
91 EntryList iNodeList;//To hold root directory entry |
|
92 }; |
|
93 |
|
94 #endif //DIRREGION_H |