author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 May 2010 14:17:14 +0300 | |
changeset 139 | 95f71bcdcdb7 |
parent 109 | b3a1d9898418 |
child 200 | 73ea206103e6 |
permissions | -rw-r--r-- |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// fileserver\sfat32\inc\sl_std.h |
|
15 |
// |
|
16 |
||
17 |
/** |
|
18 |
@file |
|
19 |
@internalTechnology |
|
20 |
*/ |
|
21 |
||
22 |
#ifndef SL_STD_H |
|
23 |
#define SL_STD_H |
|
24 |
||
25 |
||
26 |
// |
|
27 |
// #define _DEBUG_RELEASE |
|
28 |
// |
|
29 |
||
30 |
#include "common.h" |
|
31 |
#include <f32ver.h> |
|
32 |
#include <e32svr.h> |
|
33 |
#include <kernel/localise.h> |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
34 |
|
0 | 35 |
#include "filesystem_fat.h" |
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
36 |
using namespace FileSystem_FAT; |
0 | 37 |
|
38 |
#include "common_constants.h" |
|
39 |
#include "sl_bpb.h" |
|
40 |
#include "fat_config.h" |
|
41 |
#include "fat_dir_entry.h" |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
42 |
#include "bit_vector.h" |
0 | 43 |
|
36
538db54a451d
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
44 |
|
0 | 45 |
|
46 |
#ifdef _DEBUG |
|
47 |
_LIT(KThisFsyName,"EFAT32.FSY"); ///< This FSY name |
|
48 |
#endif |
|
49 |
||
50 |
//----------------------------------------------------------------------------- |
|
51 |
//-- FAT32 specific declarations |
|
52 |
||
53 |
const TUint32 KFat32EntryMask = 0x0FFFFFFF; |
|
54 |
||
55 |
//----------------------------------------------------------------------------- |
|
56 |
||
57 |
class CFatMountCB; |
|
58 |
class CFatFileSystem; |
|
59 |
||
60 |
/** |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
61 |
Represents the position of a directory entry in terms of a cluster and offset into it |
0 | 62 |
*/ |
63 |
class TEntryPos |
|
64 |
{ |
|
65 |
public: |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
66 |
TEntryPos() : iCluster(EOF_32Bit), iPos(0) {} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
67 |
TEntryPos(TUint aCluster,TUint aPos) : iCluster(aCluster), iPos(aPos) {} |
0 | 68 |
|
69 |
inline TUint32 Cluster() const; |
|
70 |
inline TUint32 Pos() const; |
|
71 |
inline TBool operator==(const TEntryPos& aRhs) const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
72 |
inline void SetEndOfDir(); |
0 | 73 |
|
74 |
public: |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
75 |
TUint32 iCluster; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
76 |
TUint32 iPos; |
0 | 77 |
}; |
78 |
||
79 |
||
80 |
/** |
|
81 |
Interface class between the file system and the local drive media interface, |
|
82 |
handles incomplete writes to media with the ability to notify the user. |
|
83 |
This class can't be instantinated by user; only CFatMountCB can do this; see CFatMountCB::DriveInterface() |
|
84 |
||
85 |
*/ |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
class TDriveInterface |
0 | 87 |
{ |
88 |
public: |
|
89 |
enum TAction {ERetry=1}; |
|
90 |
||
91 |
public: |
|
92 |
||
93 |
//-- public interface to the local drive. Provides media driver's error handling (critical and non-critical user notifiers) |
|
94 |
//-- and thread-safety if required. |
|
95 |
TInt ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const; |
|
96 |
TInt ReadNonCritical(TInt64 aPos,TInt aLength,TDes8& aTrg) const; |
|
97 |
TInt ReadCritical(TInt64 aPos,TInt aLength,TDes8& aTrg) const; |
|
98 |
||
99 |
TInt WriteCritical(TInt64 aPos,const TDesC8& aSrc); |
|
100 |
TInt WriteNonCritical(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset); |
|
101 |
||
102 |
TInt GetLastErrorInfo(TDes8& aErrorInfo) const; |
|
103 |
||
104 |
//-- lock the mutex guarding CProxyDrive interface in order to be sure that no other thread can access it. |
|
105 |
//-- The thread that calls this method may be suspended until another signals the mutex, i.e. leaves the critical section. |
|
106 |
inline void AcquireLock() const {iProxyDrive.EnterCriticalSection();} |
|
107 |
||
108 |
//-- release the mutex guarding CProxyDrive. |
|
109 |
inline void ReleaseLock() const {iProxyDrive.LeaveCriticalSection();} |
|
110 |
||
111 |
||
112 |
protected: |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
TDriveInterface(); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
114 |
~TDriveInterface() {Close();} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
115 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
116 |
//-- outlawed |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
TDriveInterface(const TDriveInterface&); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
TDriveInterface& operator=(const TDriveInterface&); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
119 |
void* operator new(TUint); //-- disable creating objets of this class on the heap. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
120 |
void* operator new(TUint, void*); |
0 | 121 |
|
122 |
TBool Init(CFatMountCB* aMount); |
|
123 |
void Close(); |
|
124 |
||
125 |
inline TBool NotifyUser() const; |
|
126 |
TInt HandleRecoverableError(TInt aRes) const; |
|
127 |
TInt HandleCriticalError(TInt aRes) const; |
|
128 |
TInt UnlockAndReMount() const; |
|
129 |
TBool IsDriveWriteProtected() const; |
|
130 |
TBool IsRecoverableRemount() const; |
|
131 |
||
132 |
private: |
|
133 |
||
134 |
/** |
|
135 |
An internal class that represents a thread-safe wrapper around raw interface to the CProxyDrive |
|
136 |
and restricts access to it. |
|
137 |
*/ |
|
138 |
class XProxyDriveWrapper |
|
139 |
{ |
|
140 |
public: |
|
141 |
||
142 |
XProxyDriveWrapper(); |
|
143 |
~XProxyDriveWrapper(); |
|
144 |
||
145 |
TBool Init(CProxyDrive* aProxyDrive); |
|
146 |
||
147 |
inline void EnterCriticalSection() const {iLock.Wait();} |
|
148 |
inline void LeaveCriticalSection() const {iLock.Signal();} |
|
149 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
//-- methods' wrappers that are used by TDriveInterface |
0 | 151 |
TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const; |
152 |
TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const; |
|
153 |
TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset); |
|
154 |
TInt Write(TInt64 aPos, const TDesC8& aSrc); |
|
155 |
TInt GetLastErrorInfo(TDes8& aErrorInfo) const; |
|
156 |
TInt Caps(TDes8& anInfo) const; |
|
157 |
||
158 |
private: |
|
159 |
CProxyDrive* iLocalDrive; ///< raw interface to the media operations |
|
160 |
mutable RMutex iLock; ///< used for sorting out multithreaded access to the iLocalDrive |
|
161 |
}; |
|
162 |
||
163 |
CFatMountCB* iMount; ///< Pointer to the owning file system mount |
|
164 |
XProxyDriveWrapper iProxyDrive; ///< wrapper around raw interface to the media operations |
|
165 |
||
166 |
}; |
|
167 |
||
168 |
||
169 |
/** |
|
170 |
Class providing FAT table interface and basic functionality. |
|
171 |
*/ |
|
172 |
class CFatTable : public CBase |
|
173 |
{ |
|
174 |
||
175 |
public: |
|
176 |
||
177 |
virtual ~CFatTable(); |
|
178 |
||
179 |
static CFatTable* NewL(CFatMountCB& aOwner, const TLocalDriveCaps& aLocDrvCaps); |
|
180 |
||
181 |
/** FAT table mounting parameters */ |
|
182 |
struct TMountParams |
|
183 |
{ |
|
184 |
TMountParams() :iFreeClusters(0), iFirstFreeCluster(0), iFsInfoValid(0) {}; |
|
185 |
||
186 |
TUint32 iFreeClusters; ///< Free clusters count, obtained from FSInfo |
|
187 |
TUint32 iFirstFreeCluster; ///< First free cluster, obtained from FSInfo |
|
188 |
TUint32 iFsInfoValid : 1; ///< ETrue if the information in iFreeClusters & iFirstFreeCluster is valid |
|
189 |
}; |
|
190 |
||
191 |
//----------------------------------------------------------------- |
|
192 |
//-- pure virtual interface |
|
193 |
virtual TUint32 ReadL(TUint32 aFatIndex) const = 0; |
|
194 |
virtual void WriteL(TUint32 aFatIndex, TUint32 aValue) = 0; |
|
195 |
virtual TInt64 DataPositionInBytes(TUint32 aCluster) const = 0; |
|
196 |
virtual void MountL(const TMountParams& aMountParam) = 0; |
|
197 |
//----------------------------------------------------------------- |
|
198 |
//-- just virtual interface |
|
199 |
||
200 |
virtual void Dismount(TBool /*aDiscardDirtyData*/) {} |
|
201 |
virtual void FlushL() {}; |
|
202 |
||
203 |
virtual void InvalidateCacheL() {}; |
|
204 |
virtual void InvalidateCacheL(TInt64 /*aPos*/,TUint32 /*aLength*/) {}; |
|
205 |
||
206 |
virtual void FreeClusterListL(TUint32 aCluster); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
207 |
virtual void ExtendClusterListL(TUint32 aNumber, TUint32& aCluster); |
0 | 208 |
|
209 |
virtual TUint32 AllocateSingleClusterL(TUint32 aNearestCluster); |
|
210 |
virtual TUint32 AllocateClusterListL(TUint32 aNumber,TUint32 aNearestCluster); |
|
211 |
||
212 |
virtual void RequestRawWriteAccess(TInt64 /*aPos*/, TUint32 /*aLen*/) const {}; |
|
213 |
||
214 |
virtual TUint32 FreeClusterHint() const; |
|
215 |
virtual TUint32 NumberOfFreeClusters(TBool aSyncOperation=EFalse) const; |
|
216 |
virtual TBool RequestFreeClusters(TUint32 aClustersRequired) const; |
|
217 |
||
218 |
virtual void InitializeL(); |
|
219 |
virtual TBool ConsistentState() const {return ETrue;} //-- dummy |
|
220 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
221 |
virtual TUint32 CountContiguousClustersL(TUint32 aStartCluster, TUint32& anEndCluster, TUint32 aMaxCount) const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
222 |
|
0 | 223 |
//----------------------------------------------------------------- |
224 |
//-- non-virtual interface |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
225 |
TBool GetNextClusterL(TUint32& aCluster) const; |
0 | 226 |
void WriteFatEntryEofL(TUint32 aFatIndex); |
227 |
||
228 |
void MarkAsBadClusterL(TUint32 aCluster); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
229 |
|
0 | 230 |
|
231 |
inline TUint32 MaxEntries() const; |
|
232 |
||
233 |
TUint32 PosInBytes(TUint32 aFatIndex) const; |
|
234 |
||
235 |
||
236 |
protected: |
|
237 |
CFatTable(CFatMountCB& aOwner); |
|
238 |
||
239 |
//-- outlawed |
|
240 |
CFatTable(); |
|
241 |
CFatTable(const CFatTable&); |
|
242 |
CFatTable& operator=(const CFatTable&); |
|
243 |
||
244 |
virtual void SetFreeClusterHint(TUint32 aCluster); |
|
245 |
||
246 |
virtual void DecrementFreeClusterCount(TUint32 aCount); |
|
247 |
virtual void IncrementFreeClusterCount(TUint32 aCount); |
|
248 |
||
249 |
virtual void SetFreeClusters(TUint32 aFreeClusters); |
|
250 |
virtual void CountFreeClustersL(); |
|
251 |
virtual TUint32 FindClosestFreeClusterL(TUint32 aCluster); |
|
252 |
||
253 |
||
254 |
inline TInt SectorSizeLog2() const; |
|
255 |
inline TUint32 FreeClusters() const; |
|
256 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
inline TBool IsEndOfClusterCh(TUint32 aCluster) const; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
|
0 | 259 |
|
260 |
inline TFatType FatType() const; |
|
261 |
inline TBool IsFat12() const; |
|
262 |
inline TBool IsFat16() const; |
|
263 |
inline TBool IsFat32() const; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
|
0 | 265 |
|
266 |
inline TBool ClusterNumberValid(TUint32 aClusterNo) const; |
|
267 |
||
268 |
typedef RArray<TUint> RClusterArray; |
|
269 |
void DoFreedClustersNotify(RClusterArray &aFreedClusters); |
|
270 |
||
271 |
||
272 |
protected: |
|
273 |
||
274 |
CFatMountCB* iOwner; ///< Owning file system mount |
|
275 |
TUint iMediaAtt; ///< Cached copy of TLocalDriveCaps::iMediaAtt |
|
276 |
||
277 |
private: |
|
278 |
||
279 |
TUint32 iFreeClusters; ///< Number of free cluster in the fat table |
|
280 |
TUint32 iFreeClusterHint; ///< this is just a hint to the free cluster number, not required to contain exact information. |
|
281 |
TFatType iFatType; ///< FAT type 12/16/32, cached from the iOwner |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
TUint32 iFatEocCode; ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 |
0 | 283 |
TUint32 iMaxEntries; ///< maximal number of FAT entries in the table. This value is taken from the CFatMount that calculates it |
284 |
||
285 |
}; |
|
286 |
||
287 |
||
288 |
class MWTCacheInterface; |
|
289 |
||
290 |
||
291 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
292 |
||
293 |
/** |
|
294 |
Base class abstraction of a raw media disk |
|
295 |
*/ |
|
296 |
||
297 |
||
298 |
class CRawDisk : public CBase |
|
299 |
{ |
|
300 |
public: |
|
301 |
||
302 |
static CRawDisk* NewL(CFatMountCB& aOwner, const TLocalDriveCaps& aLocDrvCaps); |
|
303 |
||
304 |
virtual void InitializeL(); |
|
305 |
||
306 |
virtual TInt GetLastErrorInfo(TDes8& aErrorInfo) const; |
|
307 |
public: |
|
308 |
||
309 |
/** |
|
310 |
Read data from the media via simple WT data cache if it is present. Some media types, like RAM do not have caches. |
|
311 |
This method is mostly used to read UIDs of executable modules and store them in the cache. |
|
312 |
||
313 |
@param aPos Media position in bytes |
|
314 |
@param aLength Length in bytes of read |
|
315 |
@param aDes Data from read |
|
316 |
*/ |
|
317 |
virtual void ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const = 0; |
|
318 |
||
319 |
/** |
|
320 |
Write data to the media via simple WT data cache if it is present. Some media types, like RAM do not have caches. |
|
321 |
@param aPos Media position in bytes |
|
322 |
@param aDes Data to write |
|
323 |
*/ |
|
324 |
virtual void WriteCachedL(TInt64 aPos,const TDesC8& aDes) = 0; |
|
325 |
||
326 |
virtual void InvalidateUidCache() {} |
|
327 |
virtual void InvalidateUidCachePage(TUint64 /*aPos*/) {} |
|
328 |
||
329 |
||
330 |
/** |
|
331 |
Disk read function |
|
332 |
||
333 |
@param aPos Media position in bytes |
|
334 |
@param aLength Length in bytes of read |
|
335 |
@param aTrg Pointer to the data descriptor, i.e. (const TAny*)(&TDes8) |
|
336 |
@param aMessage Refrence to server message from request |
|
337 |
@param anOffset Offset into read data to write |
|
338 |
*/ |
|
339 |
virtual void ReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const = 0; |
|
340 |
||
341 |
/** |
|
342 |
Disk write function |
|
343 |
||
344 |
@param aPos Media position in bytes |
|
345 |
@param aLength Length in bytes of write |
|
346 |
@param aTrg Pointer to the data descriptor, i.e. (const TAny*)(&TDes8) |
|
347 |
@param aMessage Refrence to server message from request, contains data |
|
348 |
@param anOffset Offset into write data to use in write |
|
349 |
*/ |
|
350 |
virtual void WriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset) = 0; |
|
351 |
||
352 |
||
353 |
virtual inline MWTCacheInterface* DirCacheInterface(); |
|
354 |
||
355 |
||
356 |
||
357 |
||
358 |
protected: |
|
359 |
||
360 |
CRawDisk(CFatMountCB& aOwner); |
|
361 |
||
362 |
//-- outlawed |
|
363 |
CRawDisk(); |
|
364 |
CRawDisk(const CRawDisk&); |
|
365 |
CRawDisk& operator=(const CRawDisk&); |
|
366 |
||
367 |
||
368 |
protected: |
|
369 |
||
370 |
CFatMountCB* iFatMount; ///< Owning file system mount |
|
371 |
||
372 |
||
373 |
||
374 |
}; |
|
375 |
||
376 |
class CFatFileCB; |
|
377 |
class RBitVector; |
|
378 |
||
379 |
/** |
|
380 |
A helper class. Holds the FAT volume parameters, which in turn are obtained from the Boot Sector |
|
381 |
*/ |
|
382 |
class TFatVolParam |
|
383 |
{ |
|
384 |
public: |
|
385 |
||
386 |
TFatVolParam(); |
|
387 |
void Populate(const TFatBootSector& aBootSector); |
|
388 |
TBool operator==(const TFatVolParam& aRhs) const; |
|
389 |
||
390 |
//-- simple getters |
|
391 |
TUint32 ClusterSizeLog2() const {return iClusterSizeLog2; } |
|
392 |
TUint32 SectorSizeLog2() const {return iSectorSizeLog2; } |
|
393 |
TUint32 RootDirEnd() const {return iRootDirEnd; } |
|
394 |
TUint32 SectorsPerCluster() const {return iSectorsPerCluster; } |
|
395 |
TUint32 RootDirectorySector() const {return iRootDirectorySector;} |
|
396 |
TUint32 FirstFatSector() const {return iFirstFatSector; } |
|
397 |
TUint32 TotalSectors() const {return iTotalSectors; } |
|
398 |
TUint32 NumberOfFats() const {return iNumberOfFats; } |
|
399 |
TUint32 FatSizeInBytes() const {return iFatSizeInBytes; } |
|
400 |
TUint32 RootClusterNum() const {return iRootClusterNum; } |
|
401 |
TUint32 FSInfoSectorNum() const {return iFSInfoSectorNum; } |
|
402 |
TUint32 BkFSInfoSectorNum() const {return iBkFSInfoSectorNum; } |
|
403 |
||
404 |
protected: |
|
405 |
TUint32 iClusterSizeLog2; ///< Log2 of fat file system cluster size |
|
406 |
TUint32 iSectorSizeLog2; ///< Log2 of media sector size |
|
407 |
TUint32 iRootDirEnd; ///< End position of the root directory for Fat12/16 |
|
408 |
TUint32 iSectorsPerCluster; ///< Sector per cluster ratio for mounted Fat file system volume |
|
409 |
TUint32 iRootDirectorySector; ///< Start sector of the root directory for Fat12/16 |
|
410 |
TUint32 iFirstFatSector; ///< Start sector of the first Fat table in volume |
|
411 |
TUint32 iTotalSectors; ///< Total sectors on media partition |
|
412 |
TUint32 iNumberOfFats; ///< Number of Fats the volume has |
|
413 |
TUint32 iFatSizeInBytes; ///< Size of a single Fat table in volume |
|
414 |
TUint32 iRootClusterNum; ///< Cluster number for Root directory, for Fat32 |
|
415 |
TUint32 iFSInfoSectorNum; ///< FSInfo Sector number. If 0, this means that corresponding value isn't set in BPB |
|
416 |
TUint32 iBkFSInfoSectorNum; ///< backup FSInfo Sector number |
|
417 |
}; |
|
418 |
||
419 |
||
420 |
TBool IsLegalDosName(const TDesC& aName, TBool anAllowWildCards, TBool aUseExtendedChars, TBool aInScanDrive, TBool aAllowLowerCase, TBool aIsForFileCreation); |
|
421 |
TBool IsLegalDOSNameChar(TChar aCharacter, TBool aUseExtendedChars); |
|
422 |
||
423 |
TUint32 CalculatePageOffsetInCluster(TUint32 aPos, TUint aPageSzLog2); |
|
424 |
||
425 |
class CLruCache; |
|
426 |
class TLeafDirData; |
|
427 |
class CLeafDirCache; |
|
428 |
||
429 |
||
430 |
/** |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
431 |
Fat file system mount implementation, provides all that is required of a plug in |
0 | 432 |
file system mount as well as Fat mount specific functionality |
433 |
*/ |
|
434 |
class CFatMountCB : public CLocDrvMountCB, |
|
435 |
public MFileSystemSubType, |
|
436 |
public MFileSystemClusterSize, |
|
437 |
public CMountCB::MFileAccessor, |
|
438 |
public CMountCB::MFileExtendedInterface |
|
439 |
{ |
|
440 |
public: |
|
441 |
static CFatMountCB* NewL(); |
|
442 |
~CFatMountCB(); |
|
443 |
void ConstructL(); |
|
444 |
||
445 |
public: |
|
446 |
||
447 |
//-- overrides from the abstract CMountCB |
|
448 |
void MountL(TBool aForceMount); |
|
449 |
TInt ReMount(); |
|
450 |
void Dismounted(); |
|
451 |
void VolumeL(TVolumeInfo& aVolume) const; |
|
452 |
void SetVolumeL(TDes& aName); |
|
453 |
void MkDirL(const TDesC& aName); |
|
454 |
void RmDirL(const TDesC& aName); |
|
455 |
void DeleteL(const TDesC& aName); |
|
456 |
void RenameL(const TDesC& anOldName,const TDesC& anNewName); |
|
457 |
void ReplaceL(const TDesC& anOldName,const TDesC& anNewName); |
|
458 |
void EntryL(const TDesC& aName,TEntry& anEntry) const; |
|
459 |
void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aMask,TUint aVal); |
|
460 |
void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile); |
|
461 |
void DirOpenL(const TDesC& aName,CDirCB* aDir); |
|
462 |
void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const; |
|
463 |
void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage); |
|
464 |
void GetShortNameL(const TDesC& aLongName,TDes& aShortName); |
|
465 |
void GetLongNameL(const TDesC& aShortName,TDes& aLongName); |
|
466 |
void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage); |
|
467 |
TInt CheckDisk(); |
|
468 |
TInt ScanDrive(); |
|
469 |
TInt ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2); |
|
470 |
TInt Lock(TMediaPassword& aOld,TMediaPassword& aNew,TBool aStore); |
|
471 |
TInt Unlock(TMediaPassword& aPassword,TBool aStore); |
|
472 |
TInt ClearPassword(TMediaPassword& aPassword); |
|
473 |
TInt ErasePassword(); |
|
474 |
TInt ForceRemountDrive(const TDesC8* aMountInfo,TInt aMountInfoMessageHandle,TUint aFlags); |
|
475 |
||
476 |
void FinaliseMountL(); |
|
477 |
void FinaliseMountL(TInt aOperation, TAny* aParam1=NULL, TAny* aParam2=NULL); |
|
478 |
TInt MountControl(TInt aLevel, TInt aOption, TAny* aParam); |
|
479 |
TTimeIntervalSeconds TimeOffset() const; |
|
480 |
||
481 |
protected: |
|
482 |
||
483 |
/** CFatMountCB states */ |
|
484 |
enum TFatMntState |
|
485 |
{ |
|
486 |
ENotMounted = 0, ///< 0, initial state, not mounted (mount state is inconsistent) |
|
487 |
EMounting, ///< 1, Mounting started (mount state is inconsistent) |
|
488 |
EInit_R, ///< 2, Initialised and not written (mount state is Consistent) |
|
489 |
EInit_W, ///< 3, Initialised and written (mount state is Consistent) |
|
490 |
EFinalised, ///< 4, Finalised (mount state is Consistent) |
|
491 |
EDismounted, ///< 5, Dismounted (mount state is inconsistent) |
|
492 |
EInit_Forced, ///< 6, forcedly mounted, special case (mount state is inconsistent) |
|
493 |
}; |
|
494 |
||
495 |
inline TFatMntState State() const; |
|
496 |
inline void SetState(TFatMntState aState); |
|
497 |
TInt OpenMountForWrite(); |
|
498 |
TInt IsFinalised(TBool& aFinalised); |
|
499 |
||
500 |
/** |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
A wrapper around TDriveInterface providing its instantination and destruction. |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
502 |
You must not create objects of this class, use DriveInterface() method for obtaining the reference to the driver interface. |
0 | 503 |
*/ |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
class XDriveInterface: public TDriveInterface |
0 | 505 |
{ |
506 |
public: |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
507 |
using TDriveInterface::Init; |
0 | 508 |
}; |
509 |
||
510 |
||
511 |
public: |
|
512 |
||
513 |
enum TRenMode {EModeReplace,EModeRename}; |
|
514 |
||
515 |
TBool ConsistentState() const; |
|
516 |
void CheckWritableL() const; |
|
517 |
void CheckStateConsistentL() const; |
|
518 |
||
519 |
inline TBool ReadOnly(void) const; |
|
520 |
inline void SetReadOnly(TBool aReadOnlyMode); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
521 |
inline TUint32 StartCluster(const TFatDirEntry & anEntry) const; |
0 | 522 |
inline CRawDisk& RawDisk() const; |
523 |
inline CFatFileSystem& FatFileSystem() const; |
|
524 |
inline CFatTable& FAT() const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
525 |
inline TUint32 ClusterSizeLog2() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
526 |
inline TUint32 SectorSizeLog2() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
527 |
inline TUint32 TotalSectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
528 |
inline TUint32 SectorsPerCluster() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
529 |
inline TUint32 ClusterBasePosition() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
530 |
inline TUint32 RootDirectorySector() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
531 |
inline TUint32 RootDirEnd() const; |
0 | 532 |
inline TUint32 RootClusterNum() const; |
533 |
||
534 |
inline TFatType FatType() const; |
|
535 |
inline TBool Is16BitFat() const; |
|
536 |
inline TBool Is32BitFat() const; |
|
537 |
||
538 |
inline TUint32 MaxClusterNumber() const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
539 |
inline TUint32 StartOfFatInBytes() const; |
0 | 540 |
inline TUint32 FirstFatSector() const; |
541 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
542 |
inline TUint32 NumberOfFats() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
543 |
inline TUint32 FatSizeInBytes() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
544 |
inline TUint32 ClusterRelativePos(TUint32 aPos) const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
545 |
inline TUint32 StartOfRootDirInBytes() const; |
0 | 546 |
inline TUint32 UsableClusters() const; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
547 |
inline TBool ClusterNumberValid(TUint32 aClusterNo) const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
548 |
inline TBool IsBadCluster(TUint32 aCluster) const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
549 |
|
0 | 550 |
inline TBool IsRuggedFSys() const; |
551 |
inline void SetRuggedFSys(TBool aVal); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
552 |
inline TUint32 AtomicWriteGranularityLog2() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
553 |
|
0 | 554 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
555 |
inline TUint32 RootIndicator() const; |
0 | 556 |
|
557 |
inline TBool IsRootDir(const TEntryPos &aEntry) const; |
|
558 |
inline CAsyncNotifier* Notifier() const; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
inline TDriveInterface& DriveInterface() const; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
560 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
561 |
inline TBool IsEndOfClusterCh(TUint32 aCluster) const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
562 |
inline void SetEndOfClusterCh(TUint32 &aCluster) const; |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
563 |
|
0 | 564 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
565 |
void ReadUidL(TUint32 aCluster,TEntry& anEntry) const; |
0 | 566 |
|
567 |
void ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const; |
|
568 |
void WriteDirEntryL(const TEntryPos& aPos,const TFatDirEntry& aDirEntry); |
|
569 |
||
570 |
void DirReadL(const TEntryPos& aPos,TInt aLength,TDes8& aDes) const; |
|
571 |
void DirWriteL(const TEntryPos& aPos,const TDesC8& aDes); |
|
572 |
||
573 |
void ReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
574 |
void WriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint& aBadcluster, TUint& aGoodcluster); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
575 |
|
0 | 576 |
void MoveToNextEntryL(TEntryPos& aPos) const; |
577 |
void MoveToDosEntryL(TEntryPos& aPos,TFatDirEntry& anEntry) const; |
|
578 |
void EnlargeL(TInt aSize); |
|
579 |
void ReduceSizeL(TInt aPos,TInt aLength); |
|
580 |
void DoDismount(); |
|
581 |
TBool ProcessFSInfoSectors(CFatTable::TMountParams& aFatInitParams) const; |
|
582 |
||
583 |
||
584 |
void DoRenameOrReplaceL(const TDesC& anOldName,const TDesC& aNewName,TRenMode aMode,TEntryPos& aNewPos); |
|
585 |
void FindDosNameL(const TDesC& aName,TUint anAtt,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName,TInt anError) const; |
|
586 |
||
587 |
void Dismount(); |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
588 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
589 |
void InitializeRootEntry(TFatDirEntry & anEntry) const; |
0 | 590 |
|
591 |
TInt64 MakeLinAddrL(const TEntryPos& aPos) const; |
|
592 |
||
593 |
inline const TFatConfig& FatConfig() const; |
|
594 |
TBool CheckVolumeTheSame(); |
|
595 |
||
596 |
void InvalidateLeafDirCache(); |
|
597 |
||
598 |
void BlockMapReadFromClusterListL(TEntryPos& aPos, TInt aLength, SBlockMapInfo& aInfo); |
|
599 |
virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); |
|
600 |
virtual TInt GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId); |
|
601 |
virtual TInt Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2); |
|
602 |
virtual TInt Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2); |
|
603 |
virtual TInt Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2); |
|
604 |
||
605 |
public: |
|
606 |
||
607 |
// interface extension implementation |
|
608 |
virtual TInt SubType(TDes& aName) const; |
|
609 |
virtual TInt ClusterSize() const; |
|
610 |
virtual void ReadSection64L(const TDesC& aName, TInt64 aPos, TAny* aTrg, TInt aLength, const RMessagePtr2& aMessage); |
|
611 |
||
612 |
private: |
|
613 |
||
614 |
/** An ad hoc internal helper object for using in DoFindL() method and its derivatives */ |
|
615 |
class TFindHelper |
|
616 |
{ |
|
617 |
public: |
|
618 |
TFindHelper() {isInitialised = EFalse;} |
|
619 |
void InitialiseL(const TDesC& aTargetName); |
|
620 |
TBool MatchDosEntryName(const TUint8* apDosEntryName) const; |
|
621 |
TBool TrgtNameIsLegalDos() const {ASSERT (isInitialised) ;return isLegalDosName;} |
|
622 |
||
623 |
private: |
|
624 |
TFindHelper(const TFindHelper&); |
|
625 |
TFindHelper& operator=(const TFindHelper&); |
|
626 |
public: |
|
627 |
TPtrC iTargetName; ///< pointer to the aTargetName, used in DoRummageDirCacheL() as a parameter |
|
628 |
private: |
|
629 |
TBool isInitialised :1; ///< ETrue if the object is initialised. It can be done only once. |
|
630 |
TBool isLegalDosName :1; ///< ETrue if iTargetName is a legal DOS name |
|
631 |
TShortName iShortName; ///< a short DOS name in XXXXXXXXYYY format generated from aTargetName |
|
632 |
}; |
|
633 |
||
634 |
||
635 |
/** |
|
636 |
An ad hoc internal helper object for entry creations |
|
637 |
*/ |
|
638 |
class XFileCreationHelper |
|
639 |
{ |
|
640 |
public: |
|
641 |
XFileCreationHelper(); |
|
642 |
~XFileCreationHelper(); |
|
643 |
void Close(); |
|
644 |
void InitialiseL(const TDesC& aTargetName); |
|
645 |
TInt GetValidatedShortName(TShortName& aShortName) const; |
|
646 |
void CheckShortNameCandidates(const TUint8* apDosEntryName); |
|
647 |
||
648 |
// inline functions for sets and gets |
|
649 |
// note all the get functions have been checked against initialisation status |
|
650 |
inline TBool IsInitialised() const; |
|
651 |
inline TUint16 NumOfAddingEntries() const; |
|
652 |
inline TEntryPos EntryAddingPos()const; |
|
653 |
inline TBool IsNewEntryPosFound() const; |
|
654 |
inline TBool IsTrgNameLegalDosName() const; |
|
655 |
||
656 |
inline void SetEntryAddingPos(const TEntryPos& aEntryPos); |
|
657 |
inline void SetIsNewEntryPosFound(TBool aFound); |
|
658 |
||
659 |
private: |
|
660 |
XFileCreationHelper(const XFileCreationHelper&); |
|
661 |
XFileCreationHelper& operator=(const TFindHelper&); |
|
662 |
||
663 |
private: |
|
664 |
TPtrC iTargetName; ///< pointer to hold the long file name of the target file |
|
665 |
TUint16 iNumOfAddingEntries;///< calculated number of entries to add |
|
666 |
TEntryPos iEntryAddingPos; ///< contains new entry position for adding if found any |
|
667 |
TBool isNewEntryPosFound; ///< flags whether the position for new entries is found |
|
668 |
TBool isInitialised :1; ///< flags whether the object is initialised |
|
669 |
TBool isTrgNameLegalDosName :1; ///< flags whether the target file name is a valid Dos name |
|
670 |
/** |
|
671 |
an array that holds short name candidates, prepared on initialisation. |
|
672 |
*/ |
|
673 |
RArray<TShortName> iShortNameCandidates; |
|
674 |
}; |
|
675 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
676 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
677 |
/** a helper class that describes a continuous chunk of diectory entries*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
678 |
class TEntrySetChunkInfo |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
679 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
680 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
681 |
inline TEntrySetChunkInfo(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
682 |
inline TBool operator==(const TEntrySetChunkInfo& aRhs); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
683 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
684 |
//-- FAT entryset can't span more than 3 clusters/sectors |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
685 |
enum {KMaxChunks = 3}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
686 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
687 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
688 |
TEntryPos iEntryPos; ///< entryset chunk dir. starting position |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
689 |
TUint iNumEntries; ///< number of entries in the chunk |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
690 |
}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
691 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
692 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
693 |
void DoEraseEntrySetChunkL(const TEntrySetChunkInfo& aEntrySetChunk); |
0 | 694 |
|
695 |
||
696 |
TBool DoRummageDirCacheL(TUint anAtt,TEntryPos& aStartEntryPos,TFatDirEntry& aStartEntry,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName, const TFindHelper& aAuxParam, XFileCreationHelper* aFileCreationHelper, const TLeafDirData& aLeafDir) const; |
|
697 |
TBool DoFindL(const TDesC& aName,TUint anAtt,TEntryPos& aStartEntryPos,TFatDirEntry& aStartEntry,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName,TInt anError, XFileCreationHelper* aFileCreationHelper, const TLeafDirData& aLeafDirData) const; |
|
698 |
void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos, XFileCreationHelper* aFileCreationHelper) const; |
|
699 |
||
700 |
void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos) const; |
|
701 |
||
702 |
void CheckFatForLoopsL(const TFatDirEntry& anEntry) const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
703 |
void DoCheckFatForLoopsL(TUint32 aCluster, TUint32& aPreviousCluster, TUint32& aChangePreviousCluster, TUint32& aCount) const; |
0 | 704 |
void InitializeL(const TLocalDriveCaps& aLocDrvCaps, TBool aIgnoreFSInfo=EFalse); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
705 |
|
0 | 706 |
void DoReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
707 |
void DoWriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint aLastcluster, TUint& aBadcluster, TUint& aGoodcluster); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
708 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
709 |
TBool IsUniqueNameL(const TShortName& aName, TUint32 aDirCluster); |
0 | 710 |
TBool FindShortNameL(const TShortName& aName,TEntryPos& anEntryPos); |
711 |
void ReplaceClashingNameL(const TShortName& aNewName,const TEntryPos& anEntryPos); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
712 |
TBool GenerateShortNameL(TUint32 aDirCluster,const TDesC& aLongName,TShortName& aShortName, TBool aForceRandomize=EFalse); |
0 | 713 |
TInt FindLeafDirL(const TDesC& aName, TLeafDirData& aLeafDir) const; |
714 |
||
715 |
TInt GetDirEntry(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const; |
|
716 |
TBool DoGetDirEntryL(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const; |
|
717 |
||
718 |
void WriteDirEntryL(TEntryPos& aPos,const TFatDirEntry& aFatDirEntry,const TDesC& aLongFileName); |
|
719 |
void EraseDirEntryL(TEntryPos aPos,const TFatDirEntry& anEntry); |
|
720 |
void EraseDirEntryL(const TEntryPos& aPos); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
721 |
void InitializeFirstDirClusterL(TUint32 aCluster, TUint32 aParentCluster); |
0 | 722 |
void AddDirEntryL(TEntryPos& aPos,TInt aNameLength); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
723 |
void ZeroDirClusterL(TUint32 aCluster); |
0 | 724 |
|
725 |
TInt DoWriteBootSector(TInt64 aMediaPos, const TFatBootSector& aBootSector) const; |
|
726 |
TInt DoReadBootSector(TInt64 aMediaPos, TFatBootSector& aBootSector) const; |
|
727 |
TInt ReadBootSector(TFatBootSector& aBootSector, TBool aDoNotReadBkBootSec=EFalse); |
|
728 |
||
729 |
TInt WriteFSInfoSector(TInt64 aMediaPos, const TFSInfo& aFSInfo) const; |
|
730 |
TInt ReadFSInfoSector(TInt64 aMediaPos, TFSInfo& aFSInfo) const; |
|
731 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
732 |
TBool IsDirectoryEmptyL(TUint32 aCluster); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
733 |
void ExtendClusterListZeroedL(TUint32 aNumber, TUint32& aCluster); |
0 | 734 |
void WritePasswordData(); |
735 |
||
736 |
void WriteVolumeLabelL(const TDesC8& aVolumeLabel) const; |
|
737 |
TInt ReadVolumeLabelFile(TDes8& aLabel); |
|
738 |
void WriteVolumeLabelFileL(const TDesC8& aNewName); |
|
739 |
void FindVolumeLabelFileL(TDes8& aLabel, TEntryPos& aDosEntryPos, TFatDirEntry& aDosEntry); |
|
740 |
void GetVolumeLabelFromDiskL(const TFatBootSector& aBootSector); |
|
741 |
void TrimVolumeLabel(TDes8& aLabel) const; |
|
742 |
||
743 |
TInt DoRunScanDrive(); |
|
744 |
TBool VolumeCleanL(); |
|
745 |
void SetVolumeCleanL(TBool aClean); |
|
746 |
TBool VolCleanFlagSupported() const; |
|
747 |
||
748 |
void DoUpdateFSInfoSectorsL(TBool aInvalidateFSInfo); |
|
749 |
void UnFinaliseMountL(); |
|
750 |
void DoReMountL(); |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
751 |
void SetFatType(TFatType aFatType); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
752 |
|
0 | 753 |
|
754 |
private: |
|
755 |
||
756 |
||
757 |
CFatMountCB(); |
|
758 |
||
759 |
TInt GetDosEntryFromNameL(const TDesC& aName, TEntryPos& aDosEntryPos, TFatDirEntry& aDosEntry); |
|
760 |
||
761 |
TInt MntCtl_DoCheckFileSystemMountable(); |
|
762 |
||
763 |
||
764 |
private: |
|
765 |
||
766 |
TBool iReadOnly : 1;///< if true, the drive is in read-only mode |
|
767 |
TBool iRamDrive : 1;///< true if this is a RAM drive |
|
768 |
TBool iMainBootSecValid : 1;///< true if the main boot sector is valid, if false, a backup boot sector may be in use. |
|
769 |
||
770 |
TFatMntState iState; ///< this mounnt internal state |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
771 |
|
0 | 772 |
TFatType iFatType; ///< FAT type, FAT12,16 or 32 |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
773 |
TUint32 iFatEocCode; ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 |
0 | 774 |
|
775 |
CLeafDirCache* iLeafDirCache; ///< A cache for most recently visited directories, only valid when limit is set bigger than 1 |
|
776 |
||
777 |
TFatVolParam iVolParam; ///< FAT volume parameters, populated form the boot sector values. |
|
778 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
779 |
TUint32 iFirstFreeByte; ///< First free byte in media (start of the data area on the volume) |
0 | 780 |
TUint32 iUsableClusters; ///< Number of usable cluster on the volume |
781 |
||
782 |
CFatTable* iFatTable; ///< Pointer to the volume Fat |
|
783 |
CRawDisk* iRawDisk; ///< Pointer to the raw data interface class |
|
784 |
||
785 |
CAsyncNotifier* iNotifier; ///< Async notifier for notifying user of Fat error conditions |
|
786 |
||
787 |
XDriveInterface iDriverInterface; ///< the object representing interface to the drive, provides read/write access and notifiers |
|
788 |
TFatConfig iFatConfig; ///< FAT parametrers from estart.txt |
|
789 |
||
790 |
XFileCreationHelper iFileCreationHelper; |
|
791 |
||
792 |
||
793 |
#ifdef _DEBUG |
|
794 |
private: |
|
795 |
//-- debug odds and ends |
|
796 |
inline TBool IsWriteFail()const; |
|
797 |
inline void SetWriteFail(TBool aIsWriteFail); |
|
798 |
inline TInt WriteFailCount()const; |
|
799 |
inline void SetWriteFailCount(TInt aFailCount); |
|
800 |
inline void DecWriteFailCount(); |
|
801 |
inline TInt WriteFailError()const; |
|
802 |
inline void SetWriteFailError(TInt aErrorValue); |
|
803 |
||
804 |
||
805 |
TBool iIsWriteFail : 1; ///< Flag to indicate if write failed used for debugging |
|
806 |
TBool iCBRecFlag : 1; ///< in debug mode used for checking unwanted recursion |
|
807 |
||
808 |
TInt iWriteFailCount; ///< Write fail count for debug |
|
809 |
TInt iWriteFailError; ///< Write fail error to use for debug |
|
810 |
||
811 |
#endif |
|
812 |
||
813 |
friend class CFatFormatCB; |
|
814 |
friend class CScanDrive; |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
815 |
friend class TDriveInterface; |
0 | 816 |
}; |
817 |
||
818 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
819 |
//--------------------------------------------------------------------------------------------------------------------------------- |
0 | 820 |
|
821 |
/** |
|
822 |
Fat file system file subsession implmentation, provides all that is required of a plug in |
|
823 |
file system file as well as Fat specific functionality |
|
824 |
*/ |
|
825 |
class CFatFileCB : public CFileCB, public CFileCB::MBlockMapInterface, public CFileCB::MExtendedFileInterface |
|
826 |
{ |
|
827 |
public: |
|
828 |
CFatFileCB(); |
|
829 |
~CFatFileCB(); |
|
830 |
public: |
|
831 |
void RenameL(const TDesC& aNewName); |
|
832 |
void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
833 |
void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
834 |
void SetSizeL(TInt aSize); |
|
835 |
void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal); |
|
836 |
void FlushDataL(); |
|
837 |
void FlushAllL(); |
|
838 |
public: |
|
839 |
void CheckPosL(TUint aPos); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
840 |
void SetupL(const TFatDirEntry& aFatDirEntry, const TEntryPos& aFileDosEntryPos); |
0 | 841 |
|
842 |
// from MBlockMapInterface |
|
843 |
TInt BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos); |
|
844 |
||
845 |
// from CFileCB |
|
846 |
virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); |
|
847 |
||
848 |
// from CFileCB::MExtendedFileInterface |
|
849 |
virtual void ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset); |
|
850 |
virtual void WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset); |
|
851 |
virtual void SetSizeL(TInt64 aSize); |
|
852 |
||
853 |
private: |
|
854 |
inline CFatMountCB& FatMount() const; |
|
855 |
inline CFatTable& FAT(); |
|
856 |
inline TInt ClusterSizeLog2(); |
|
857 |
inline TInt ClusterRelativePos(TInt aPos); |
|
858 |
||
859 |
||
860 |
void FlushStartClusterL(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
861 |
TInt SeekToPosition(TUint aNewCluster, TUint aClusterOffset); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
862 |
void SetSeekIndexValueL(TUint aFileCluster,TUint aStoredCluster); |
0 | 863 |
void ResizeIndex(TInt aNewMult,TUint aNewSize); |
864 |
TInt CalcSeekIndexSize(TUint aSize); |
|
865 |
TBool IsSeekBackwards(TUint aPos); |
|
866 |
void ClearIndex(TUint aNewSize); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
867 |
void DoSetSizeL(TUint aSize, TBool aForceCachesFlush); |
0 | 868 |
void WriteFileSizeL(TUint aSize); |
869 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
870 |
//---------------------------- |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
871 |
inline TUint32 FCB_StartCluster() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
872 |
inline TUint32 FCB_FileSize() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
873 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
874 |
inline void FCB_SetStartCluster(TUint32 aVal); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
875 |
inline void FCB_SetFileSize(TUint32 aVal); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
876 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
877 |
inline TBool FileAttModified() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
878 |
inline void IndicateFileAttModified(TBool aModified); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
879 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
880 |
inline TBool FileSizeModified() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
881 |
inline void IndicateFileSizeModified(TBool aModified); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
882 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
883 |
inline TBool FileTimeModified() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
884 |
inline void IndicateFileTimeModified(TBool aModified); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
885 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
886 |
//---------------------------- |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
887 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
888 |
void CreateSeekIndex(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
889 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
890 |
void DoShrinkFileToZeroSizeL(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
891 |
void DoShrinkFileL(TUint32 aNewSize, TBool aForceCachesFlush); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
892 |
void DoExpandFileL(TUint32 aNewSize, TBool aForceCachesFlush); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
893 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
894 |
|
0 | 895 |
private: |
896 |
||
897 |
TUint32* iSeekIndex; ///< Seek index into file |
|
898 |
TInt iSeekIndexSize; ///< size of seek index |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
899 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
900 |
TUint iStartCluster; ///< Start cluster number of file |
0 | 901 |
TEntryPos iCurrentPos; ///< Current position in file data |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
902 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
903 |
TEntryPos iFileDosEntryPos; ///< File DOS dir. entry position |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
904 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
905 |
TBool iFileSizeModified :1; ///< flag, indicating that file size was modified and needs to be flushed onto the media (see FlushL()) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
906 |
TBool iFileTimeModified :1; ///< flag, indicating that file modification time was modified and needs to be flushed onto the media (see FlushL()) |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
907 |
|
0 | 908 |
}; |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
|
0 | 910 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
911 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
912 |
//--------------------------------------------------------------------------------------------------------------------------------- |
0 | 913 |
/** |
914 |
Fat file system directory subsession implmentation, provides all that is required of a plug in |
|
915 |
file system directory as well as Fat specific functionality |
|
916 |
*/ |
|
917 |
class CFatDirCB : public CDirCB |
|
918 |
{ |
|
919 |
public: |
|
920 |
static CFatDirCB* NewL(); |
|
921 |
~CFatDirCB(); |
|
922 |
public: |
|
923 |
void ReadL(TEntry& anEntry); |
|
924 |
void StoreLongEntryNameL(const TDesC& aName); |
|
925 |
public: |
|
926 |
void SetDirL(const TFatDirEntry& anEntry,const TDesC& aMatchName); |
|
927 |
inline CFatMountCB& FatMount(); |
|
928 |
private: |
|
929 |
CFatDirCB(); |
|
930 |
private: |
|
931 |
TFatDirEntry iEntry; ///< Current directory entry in this directory |
|
932 |
TEntryPos iCurrentPos; ///< Current position in directory |
|
933 |
HBufC* iMatch; ///< Current name being searched in directory (Dos Name) |
|
934 |
HBufC* iLongNameBuf; ///< Long name storage |
|
935 |
TBool iMatchUid; ///< Flag to indicate if UID matches |
|
936 |
}; |
|
937 |
||
938 |
/** |
|
939 |
Fat file system Format subsession implmentation, provides all that is required of a plug in |
|
940 |
file system format as well as Fat specific functionality |
|
941 |
*/ |
|
942 |
class CFatFormatCB : public CFormatCB |
|
943 |
{ |
|
944 |
public: |
|
945 |
CFatFormatCB(); |
|
946 |
~CFatFormatCB(); |
|
947 |
public: |
|
948 |
||
949 |
//-- overrides from CFormatCB |
|
950 |
void DoFormatStepL(); |
|
951 |
||
952 |
private: |
|
953 |
//-- overrides from CFormatCB |
|
954 |
TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); |
|
955 |
||
956 |
private: |
|
957 |
||
958 |
TInt DoProcessTVolFormatParam(const TVolFormatParam_FAT* apVolFormatParam); |
|
959 |
||
960 |
void CreateBootSectorL(); |
|
961 |
void CreateFSInfoSectorL(); |
|
962 |
void CreateReservedBootSectorL(); |
|
963 |
void InitializeFormatDataL(); |
|
964 |
void DoZeroFillMediaL(TInt64 aStartPos, TInt64 aEndPos); |
|
965 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
966 |
TInt InitFormatDataForVariableSizeDisk(TUint aDiskSizeInSectors); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
967 |
TInt InitFormatDataForFixedSizeDiskNormal(TUint aDiskSizeInSectors, const TLocalDriveCapsV6& aCaps); |
0 | 968 |
TInt InitFormatDataForFixedSizeDiskCustom(const TLDFormatInfo& aFormatInfo); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
969 |
TInt InitFormatDataForFixedSizeDiskUser(TUint aDiskSizeInSectors); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
970 |
void AdjustClusterSize(TUint aRecommendedSectorsPerCluster); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
971 |
TInt AdjustFirstDataSectorAlignment(TUint aBlockSize); |
0 | 972 |
TInt FirstDataSector() const; |
973 |
||
974 |
TInt HandleCorrupt(TInt aError); |
|
975 |
TInt BadSectorToCluster(); |
|
976 |
void TranslateL(); |
|
977 |
TInt DoTranslate(TPtr8& aBuf, RArray<TInt>& aArray); |
|
978 |
void RecordOldInfoL(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
979 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
980 |
TUint MaxFat12Sectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
981 |
TUint MaxFat16Sectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
982 |
TUint MaxFat32Sectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
983 |
|
0 | 984 |
inline TBool Is16BitFat() const; |
985 |
inline TBool Is32BitFat() const; |
|
986 |
inline CFatMountCB& FatMount(); |
|
987 |
inline CProxyDrive* LocalDrive(); |
|
988 |
TFatType SuggestFatType() const; |
|
989 |
||
990 |
private: |
|
991 |
||
992 |
TBool iVariableSize; ///< Flag to indicat if we are dealing with a variable size volume |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
993 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
994 |
TUint16 iBytesPerSector; ///< Byte per sector of media |
0 | 995 |
TInt iSectorSizeLog2; ///< Sector size in log2 |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
996 |
TUint8 iNumberOfFats; ///< Number of Fats the volume will contain |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
997 |
TUint iReservedSectors; ///< Number of reserved sectors in the volume |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
998 |
TUint16 iRootDirEntries; ///< Nummer of root directory entries the root dir will have, specific to Fat12/16 volumes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
999 |
TUint iSectorsPerCluster; ///< Sector per cluster ration the volume will be formatted with |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1000 |
TUint iSectorsPerFat; ///< Number of sectors the Fat uses |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1001 |
TUint32 iMaxDiskSectors; ///< number of sectors the volume has |
0 | 1002 |
TFormatInfo iFormatInfo; ///< format information for a custom format |
1003 |
TBuf8<16> iFileSystemName;///< Buffer to contain the volume name |
|
1004 |
TInt iHiddenSectors; ///< Number of hidden sectors in the volume |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1005 |
TUint16 iNumberOfHeads; ///< Number of heads the media device has, not used so far as only used on solid state media. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1006 |
TUint16 iSectorsPerTrack; ///< Number of sectors the media device has, not used so far as only used on solid state media. |
0 | 1007 |
TUint32 iRootClusterNum; ///< cluster number used for root directory, Fat32 specific |
1008 |
TUint32 iCountOfClusters; ///< Count of clusters on the media |
|
1009 |
RArray<TInt> iBadClusters; ///< Array of bad cluster numbers |
|
1010 |
RArray<TInt> iBadSectors; ///< Array of bad sector numbers |
|
1011 |
TBool iDiskCorrupt; ///< Disk is corrupt when format or not |
|
1012 |
TInt iOldFirstFreeSector; |
|
1013 |
TInt iOldSectorsPerCluster; |
|
1014 |
}; |
|
1015 |
||
1016 |
/** |
|
1017 |
Required file system class used by file server to create the file system objects |
|
1018 |
*/ |
|
1019 |
class CFatFileSystem : public CFileSystem |
|
1020 |
{ |
|
1021 |
public: |
|
1022 |
static CFatFileSystem* New(); |
|
1023 |
~CFatFileSystem(); |
|
1024 |
public: |
|
1025 |
TInt Install(); |
|
1026 |
CMountCB* NewMountL() const; |
|
1027 |
CFileCB* NewFileL() const; |
|
1028 |
CDirCB* NewDirL() const; |
|
1029 |
CFormatCB* NewFormatL() const; |
|
1030 |
TInt DefaultPath(TDes& aPath) const; |
|
1031 |
TBool IsExtensionSupported() const; |
|
1032 |
TBool GetUseLocalTime() const; |
|
1033 |
void SetUseLocalTime(TBool aFlag); |
|
1034 |
TInt GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput); |
|
1035 |
protected: |
|
1036 |
CFatFileSystem(); |
|
1037 |
/** |
|
1038 |
If true, then local time will be used when writing timestamps to FS. When reading, |
|
1039 |
timestamps will be assumed local and converted back to UTC. |
|
1040 |
At present, this behaviour will also be conditional upon a particular drive being logically removable. |
|
1041 |
*/ |
|
1042 |
TBool iUseLocalTimeIfRemovable; |
|
1043 |
}; |
|
1044 |
||
1045 |
||
1046 |
||
1047 |
/** |
|
1048 |
Locale utilities allows the file system to call into a specific locale for tasks |
|
1049 |
such as Dos name to unicode conversions and testing the legality of characters for |
|
1050 |
any given locale. |
|
1051 |
*/ |
|
1052 |
class LocaleUtils |
|
1053 |
||
1054 |
{ |
|
1055 |
public: |
|
1056 |
static void ConvertFromUnicodeL(TDes8& aForeign, const TDesC16& aUnicode, TFatUtilityFunctions::TOverflowAction aOverflowAction=TFatUtilityFunctions::EOverflowActionTruncate); |
|
1057 |
static void ConvertToUnicodeL(TDes16& aUnicode, const TDesC8& aForeign, TFatUtilityFunctions::TOverflowAction aOverflowAction=TFatUtilityFunctions::EOverflowActionTruncate); |
|
1058 |
static TBool IsLegalShortNameCharacter(TUint aCharacter,TBool aUseExtendedChars=EFalse); |
|
1059 |
}; |
|
1060 |
// |
|
1061 |
||
1062 |
/** |
|
1063 |
Converts Dos time (from a directory entry) to TTime format |
|
1064 |
||
1065 |
@param aDosTime Dos format time |
|
1066 |
@param aDosDate Dos format Date |
|
1067 |
@return TTime format of Dos time passed in |
|
1068 |
*/ |
|
1069 |
TTime DosTimeToTTime(TInt aDosTime,TInt aDosDate); |
|
1070 |
/** |
|
1071 |
Converts TTime format to Dos time format |
|
1072 |
||
1073 |
@param aTime TTime to convert to Dos time |
|
1074 |
@return Dos time format |
|
1075 |
*/ |
|
1076 |
TInt DosTimeFromTTime(const TTime& aTime); |
|
1077 |
/** |
|
1078 |
Converts TTime format to Dos time format |
|
1079 |
||
1080 |
@param aTime TTime to convert to Dos Date |
|
1081 |
@return Dos Date format |
|
1082 |
*/ |
|
1083 |
TInt DosDateFromTTime(const TTime& aTime); |
|
1084 |
/** |
|
1085 |
Converts Dos Directory entry format to 8.3 format |
|
1086 |
||
1087 |
@param aDosName Directory entry format with space delimeter |
|
1088 |
@return 8.3 Dos filename format |
|
1089 |
*/ |
|
1090 |
TBuf8<12> DosNameToStdFormat(const TDesC8& aDosName); |
|
1091 |
/** |
|
1092 |
Converts 8.3 format to Dos Directory entry format |
|
1093 |
||
1094 |
@param aStdFormatName 8.3 Dos filename format |
|
1095 |
@return Directory entry format with space delimeter |
|
1096 |
*/ |
|
1097 |
TBuf8<12> DosNameFromStdFormat(const TDesC8& aStdFormatName); |
|
1098 |
/** |
|
1099 |
Fault function calls user panic with a fault reason |
|
1100 |
||
1101 |
@param Enumerated fault reason |
|
1102 |
*/ |
|
1103 |
void Fault(TFault aFault); |
|
1104 |
/** |
|
1105 |
calculates the number of VFat directory entries for a given file/directory name length |
|
1106 |
||
1107 |
@param the length in characters of the name |
|
1108 |
@return the number of VFat entries required |
|
1109 |
*/ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
1110 |
TUint NumberOfVFatEntries(TUint aNameLength); |
0 | 1111 |
/** |
1112 |
Calculates the check sum for a standard directory entry |
|
1113 |
||
1114 |
@param the Dos name for the directory entry |
|
1115 |
@return the checksum |
|
1116 |
*/ |
|
1117 |
TUint8 CalculateShortNameCheckSum(const TDesC8& aShortName); |
|
1118 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1119 |
TUint32 EocCodeByFatType(TFatType aFatType); |
0 | 1120 |
|
1121 |
||
1122 |
#include "sl_std.inl" |
|
1123 |
#include "sl_bpb.inl" |
|
1124 |
#include "fat_dir_entry.inl" |
|
1125 |
||
1126 |
#endif //SL_STD_H |