Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat\inc\sl_scandrv.h
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35 //---------------------------------------------------------------------------------------------------------------------------------
37 const TInt KMaxMatchingEntries = 2; ///< Maximum number of matching directory entries scan drive can fix. Any more indicates a fault in the file system
38 const TInt KMaxArrayDepth = 6; ///< Maximum array depth for cluster storage when KMaxScanDepth is reached
40 //---------------------------------------------------------------------------------------------------------------------------------
43 Data structure used to store the location of a partial VFat entry
47 TEntryPos iEntryPos; ///< The position of the partial VFat entry
48 TFatDirEntry iEntry; ///< The Dos entry The VFat entries belong with
51 //---------------------------------------------------------------------------------------------------------------------------------
54 Data structure used to store the locations of entries with matching
55 start cluster numbers.
57 struct TMatchingStartCluster
59 TEntryPos iEntries[KMaxMatchingEntries]; ///< The positions of the matching entries
60 TInt iCount; ///< Count of matching entries
61 TInt iStartCluster; ///< The matching cluster number found in more than one entry
65 //---------------------------------------------------------------------------------------------------------------------------------
67 class CCheckFatTable : public CBase
70 static CCheckFatTable* NewL(CFatMountCB* aOwner);
71 CCheckFatTable(CFatMountCB* aOwner);
75 TBool GetNextClusterL(TInt& aCluster) const;
76 void WriteFatEntryEofFL(TInt aCluster);
77 TInt ReadL(TInt aFatIndex) const;
78 void WriteL(TInt aFatIndex,TInt aValue);
80 void WriteMediaDescriptor();
81 TInt PosInBytes(TInt aFatIndex) const;
82 TInt PosInIndex(TInt aBytePos) const;
83 inline TBool IsEof16Bit(TInt aCluster) const;
84 inline TBool IsEof12Bit(TInt aCluster) const;
85 inline TInt MaxFatIndex() const;
93 //---------------------------------------------------------------------------------------------------------------------------------
96 Scan drive class performs scan drive functionality on all types
99 class CScanDrive : public CBase
102 enum TDirError{EScanMatchingEntry=1,EScanPartEntry};
106 static CScanDrive* NewL(CFatMountCB* aMount);
107 void ConstructL(CFatMountCB* aMount);
109 TBool ProblemsDiscovered() const;
114 #if defined(DEBUG_SCANDRIVE)
116 void CompareFatsL() const;
119 void FixupDirErrorL();
120 void FindSameStartClusterL();
121 TInt FindStartClusterL(TInt aDirCluster);
122 void CheckDirStructureL();
123 void CheckDirL(TInt aCluster);
124 void ProcessEntryL(const TFatDirEntry& aEntry);
125 TInt CheckEntryClusterL(const TFatDirEntry& aEntry, const TEntryPos& aEntryPos);
126 void WriteClusterChainL(TInt aCluster,TInt aSizeInBytes);
127 TBool MoveToVFatEndL(TEntryPos& aPos,TFatDirEntry& aEntry,TInt& aDirLength);
128 TBool IsValidVFatEntry(const TFatDirEntry& aEntry,TInt prevNum)const;
129 TBool IsDosEntry(const TFatDirEntry& aEntry)const;
130 void AddPartialVFatL(const TEntryPos& aStartPos, const TFatDirEntry& aEntry);
131 TBool AddMatchingEntryL(const TEntryPos& aEntryPos);
132 TInt GetReservedidL(const TEntryPos aVFatPos);
133 void WriteNewFatsL();
134 void FixPartEntryL();
135 void FixMatchingEntryL();
136 void MovePastEntriesL(TEntryPos& aEntryPos,TFatDirEntry& aEntry,TInt aToMove,TInt& aDirEntries);
137 void AddToClusterListL(TInt aCluster);
138 inline TBool AlreadyExistsL(TInt aCluster)const;
139 inline TBool IsEndOfRootDir(const TEntryPos& aPos)const;
140 inline TBool IsEofF(TInt aVal)const;
141 inline TBool IsDirError()const;
142 void IndicateErrorsFound();
146 CCheckFatTable* iNewFat;
147 TPartVFatEntry iPartEntry;
148 TMatchingStartCluster iMatching;
151 TInt iRecursiveDepth;
152 RArray<TInt>* iClusterListArray[KMaxArrayDepth];
153 TInt iListArrayIndex;
154 TBool iFoundProblems; ///< if ETrue after finish, it means that there where some problems FS structure and they were probably fixed;
161 #endif //SL_SCANDRV_H