author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 07 Jan 2010 13:38:45 +0200 | |
changeset 33 | 0173bcd7697c |
parent 0 | a41df078684a |
child 36 | 538db54a451d |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-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 |
// f32\sfat32\inc\sl_std.inl |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#ifndef SL_STD_INL |
|
19 |
#define SL_STD_INL |
|
20 |
||
21 |
||
22 |
||
23 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
24 |
// class TEntryPos |
|
25 |
TUint32 TEntryPos::Cluster() const |
|
26 |
{ |
|
27 |
return (TUint32) iCluster; |
|
28 |
} |
|
29 |
||
30 |
TUint32 TEntryPos::Pos() const |
|
31 |
{ |
|
32 |
return (TUint32) iPos; |
|
33 |
} |
|
34 |
||
35 |
TBool TEntryPos::operator==(const TEntryPos& aRhs) const |
|
36 |
{ |
|
37 |
ASSERT(this != &aRhs); |
|
38 |
return (iCluster == aRhs.iCluster && iPos == aRhs.iPos); |
|
39 |
} |
|
40 |
||
41 |
||
42 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
43 |
// class CFatMountCB |
|
44 |
||
45 |
inline TInt CFatMountCB::RootDirectorySector() const |
|
46 |
{return iVolParam.RootDirectorySector();} |
|
47 |
||
48 |
inline TUint CFatMountCB::RootDirEnd() const |
|
49 |
{return iVolParam.RootDirEnd();} |
|
50 |
||
51 |
inline TUint32 CFatMountCB::RootClusterNum() const |
|
52 |
{return iVolParam.RootClusterNum(); } |
|
53 |
||
54 |
||
55 |
inline TInt CFatMountCB::StartCluster(const TFatDirEntry & anEntry) const |
|
56 |
{ |
|
57 |
if(Is32BitFat()) |
|
58 |
return anEntry.StartCluster(); |
|
59 |
else |
|
60 |
return 0xFFFF&anEntry.StartCluster(); |
|
61 |
} |
|
62 |
||
63 |
/** |
|
64 |
returns true for root dir on Fat12/16 (fixed root dir versions of Fat) false on fat32 |
|
65 |
this function is used to handle special cases for reading/writing the root directory on FAT via the use of cluster zero. |
|
66 |
||
67 |
@param aEntry position on volume being queried |
|
68 |
@return Whether Root dir position or not |
|
69 |
*/ |
|
70 |
TBool CFatMountCB::IsRootDir(const TEntryPos &aEntry) const |
|
71 |
{ |
|
72 |
if(Is32BitFat()) |
|
73 |
return EFalse; |
|
74 |
else |
|
75 |
return((aEntry.iCluster==0) ? (TBool)ETrue : (TBool)EFalse); |
|
76 |
} |
|
77 |
/** |
|
78 |
Indicates the root directory cluster, For Fat12/16 root is always indicated by cluster number zero, on Fat32 the is a root cluster number |
|
79 |
@return The root cluster indicator |
|
80 |
*/ |
|
81 |
TInt CFatMountCB::RootIndicator() const |
|
82 |
{ |
|
83 |
if(Is32BitFat()) |
|
84 |
return iVolParam.RootClusterNum(); |
|
85 |
else |
|
86 |
return 0; |
|
87 |
} |
|
88 |
||
89 |
||
90 |
/** @return Log2 of cluster size on volume */ |
|
91 |
TInt CFatMountCB::ClusterSizeLog2() const |
|
92 |
{return(iVolParam.ClusterSizeLog2());} |
|
93 |
||
94 |
/** @return Log2 of media sector size */ |
|
95 |
TInt CFatMountCB::SectorSizeLog2() const |
|
96 |
{return(iVolParam.SectorSizeLog2());} |
|
97 |
||
98 |
/** @return sector per cluster */ |
|
99 |
TInt CFatMountCB::SectorsPerCluster() const |
|
100 |
{return(1<<(iVolParam.ClusterSizeLog2()-iVolParam.SectorSizeLog2()));} |
|
101 |
||
102 |
/** @return the base position of a cluster */ |
|
103 |
TInt CFatMountCB::ClusterBasePosition() const |
|
104 |
{return(iFirstFreeByte);} |
|
105 |
||
106 |
/** @return the offset into a cluster of a byte address */ |
|
107 |
TInt CFatMountCB::ClusterRelativePos(TInt aPos) const |
|
108 |
{return(aPos&((1<<ClusterSizeLog2())-1));} |
|
109 |
||
110 |
/** |
|
111 |
Calculates the maximum number of clusters |
|
112 |
@return maximum number of clusters |
|
113 |
*/ |
|
114 |
TUint32 CFatMountCB::MaxClusterNumber() const |
|
115 |
{return(TotalSectors()>>(ClusterSizeLog2()-SectorSizeLog2()));} |
|
116 |
||
117 |
/** @return the the total sectors on volume */ |
|
118 |
TInt CFatMountCB::TotalSectors() const |
|
119 |
{return iVolParam.TotalSectors();} |
|
120 |
||
121 |
/** @return total size of a Fat in bytes */ |
|
122 |
TInt CFatMountCB::FatSizeInBytes() const |
|
123 |
{return iVolParam.FatSizeInBytes();} |
|
124 |
||
125 |
/** @return first sector of the Fat */ |
|
126 |
TUint32 CFatMountCB::FirstFatSector() const |
|
127 |
{return iVolParam.FirstFatSector();} |
|
128 |
||
129 |
/** @return the byte offset of the Fat */ |
|
130 |
TInt CFatMountCB::StartOfFatInBytes() const |
|
131 |
{return(FirstFatSector()<<SectorSizeLog2());} |
|
132 |
||
133 |
/** @return Number of Fats used by the volume */ |
|
134 |
TInt CFatMountCB::NumberOfFats() const |
|
135 |
{return iVolParam.NumberOfFats();} |
|
136 |
||
137 |
||
138 |
/** @return refrence to the fat table owned by the mount */ |
|
139 |
CFatTable& CFatMountCB::FAT() const |
|
140 |
{return(*iFatTable);} |
|
141 |
/** |
|
142 |
@return refrence to the file system object that has produced this CFatMountCB |
|
143 |
*/ |
|
144 |
CFatFileSystem& CFatMountCB::FatFileSystem() const |
|
145 |
{ |
|
146 |
return (CFatFileSystem&)(*FileSystem()); //-- CMountCB::FileSystem() provides correct answer |
|
147 |
} |
|
148 |
||
149 |
||
150 |
/** @return refrence to a raw disk object owned by the mount */ |
|
151 |
CRawDisk& CFatMountCB::RawDisk() const |
|
152 |
{return(*iRawDisk);} |
|
153 |
||
154 |
/** |
|
155 |
@return ETrue if aCluster value is bad cluster marker defined in FAT specification |
|
156 |
*/ |
|
157 |
TBool CFatMountCB::IsBadCluster(TInt aCluster) const |
|
158 |
{return Is32BitFat() ? aCluster==0xFFFFFF7 : Is16BitFat() ? aCluster==0xFFF7 : aCluster==0xFF7;} |
|
159 |
||
160 |
/** |
|
161 |
Returns whether the current mount is running as rugged Fat or not, this is held in the file system object |
|
162 |
@return Is rugged fat flag |
|
163 |
*/ |
|
164 |
TBool CFatMountCB::IsRuggedFSys() const |
|
165 |
{return Drive().IsRugged();} |
|
166 |
||
167 |
/** |
|
168 |
Sets the rugged flag in the file system object |
|
169 |
@param Flag to set or clear the rugged flag |
|
170 |
*/ |
|
171 |
void CFatMountCB::SetRuggedFSys(TBool aVal) |
|
172 |
{Drive().SetRugged(aVal);} |
|
173 |
||
174 |
/** @return the usable clusters count for a volume */ |
|
175 |
TUint32 CFatMountCB::UsableClusters() const |
|
176 |
{return(iUsableClusters);} |
|
177 |
||
178 |
||
179 |
TUint CFatMountCB::StartOfRootDirInBytes() const |
|
180 |
{return iVolParam.RootDirectorySector()<<SectorSizeLog2();} |
|
181 |
||
182 |
||
183 |
/** @return FAT type for this mount */ |
|
184 |
TFatType CFatMountCB::FatType() const |
|
185 |
{ |
|
186 |
return iFatType; |
|
187 |
} |
|
188 |
||
189 |
/** @return ETrue if the mount has 16bit FAT */ |
|
190 |
TBool CFatMountCB::Is16BitFat() const |
|
191 |
{ |
|
192 |
return FatType() == EFat16; |
|
193 |
} |
|
194 |
||
195 |
/** @return ETrue if the mount has 32bit FAT */ |
|
196 |
TBool CFatMountCB::Is32BitFat() const |
|
197 |
{ |
|
198 |
return FatType() == EFat32; |
|
199 |
} |
|
200 |
||
201 |
CAsyncNotifier* CFatMountCB::Notifier() const |
|
202 |
{return iNotifier;} |
|
203 |
||
204 |
||
205 |
||
206 |
/** |
|
207 |
Set or reset Read Only mode for the mount. |
|
208 |
@param aReadOnlyMode if ETrue, the mount will be set RO. |
|
209 |
*/ |
|
210 |
void CFatMountCB::SetReadOnly(TBool aReadOnlyMode) |
|
211 |
{ |
|
212 |
iReadOnly = aReadOnlyMode; |
|
213 |
} |
|
214 |
||
215 |
||
216 |
/** |
|
217 |
@return ETrue if the volume is in Read-Only state |
|
218 |
*/ |
|
219 |
TBool CFatMountCB::ReadOnly(void) const |
|
220 |
{ |
|
221 |
return iReadOnly; |
|
222 |
} |
|
223 |
||
224 |
/** @return state of the CFatMountCB*/ |
|
225 |
CFatMountCB::TFatMntState CFatMountCB::State() const |
|
226 |
{ |
|
227 |
return iState; |
|
228 |
} |
|
229 |
||
230 |
/** |
|
231 |
Set state of the CFatMountCB |
|
232 |
@param aState state to set |
|
233 |
*/ |
|
234 |
void CFatMountCB::SetState(TFatMntState aState) |
|
235 |
{ |
|
236 |
__PRINT3(_L("#- CFatMountCB::SetState() drv:%d, %d->%d\n"),DriveNumber(),iState,aState); |
|
237 |
iState = aState; |
|
238 |
} |
|
239 |
||
240 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
TDriveInterface& CFatMountCB::DriveInterface() const |
0 | 242 |
{ |
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
return (TDriveInterface&)iDriverInterface; |
0 | 244 |
} |
245 |
||
246 |
const TFatConfig& CFatMountCB::FatConfig() const |
|
247 |
{ |
|
248 |
return iFatConfig; |
|
249 |
} |
|
250 |
||
251 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
252 |
/** |
|
253 |
Check if the XFileCreationHelper object is initialised. |
|
254 |
*/ |
|
255 |
TBool CFatMountCB::XFileCreationHelper::IsInitialised() const |
|
256 |
{ |
|
257 |
return isInitialised; |
|
258 |
} |
|
259 |
||
260 |
/** |
|
261 |
Get number of new entries for file creation. |
|
262 |
*/ |
|
263 |
TUint16 CFatMountCB::XFileCreationHelper::NumOfAddingEntries() const |
|
264 |
{ |
|
265 |
ASSERT(isInitialised); |
|
266 |
return iNumOfAddingEntries; |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
Get position of new entries for file creation. |
|
271 |
*/ |
|
272 |
TEntryPos CFatMountCB::XFileCreationHelper::EntryAddingPos() const |
|
273 |
{ |
|
274 |
ASSERT(isInitialised); |
|
275 |
return iEntryAddingPos; |
|
276 |
} |
|
277 |
||
278 |
/** |
|
279 |
Check if position of new entries has been found. |
|
280 |
*/ |
|
281 |
TBool CFatMountCB::XFileCreationHelper::IsNewEntryPosFound() const |
|
282 |
{ |
|
283 |
ASSERT(isInitialised); |
|
284 |
return isNewEntryPosFound; |
|
285 |
} |
|
286 |
||
287 |
/** |
|
288 |
Check if file name of the new file is a legal dos name. |
|
289 |
*/ |
|
290 |
TBool CFatMountCB::XFileCreationHelper::IsTrgNameLegalDosName() const |
|
291 |
{ |
|
292 |
ASSERT(isInitialised); |
|
293 |
return isTrgNameLegalDosName; |
|
294 |
} |
|
295 |
||
296 |
/** |
|
297 |
Set entry position for new entries to be added. |
|
298 |
*/ |
|
299 |
void CFatMountCB::XFileCreationHelper::SetEntryAddingPos(const TEntryPos& aEntryPos) |
|
300 |
{ |
|
301 |
iEntryAddingPos = aEntryPos; |
|
302 |
} |
|
303 |
||
304 |
/** |
|
305 |
Set condition if position of new entries has been found. |
|
306 |
*/ |
|
307 |
void CFatMountCB::XFileCreationHelper::SetIsNewEntryPosFound(TBool aFound) |
|
308 |
{ |
|
309 |
isNewEntryPosFound = aFound; |
|
310 |
} |
|
311 |
||
312 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
/** |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
Checks for "EOC" for all Fat types |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
@param aCluster FAT table entry (cluster number) to check |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
@return ETrue if aCluster is a EOC for the FAT type being used by CFatMountCB |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
317 |
*/ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
TBool CFatMountCB::IsEndOfClusterCh(TInt aCluster) const |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
ASSERT(iFatEocCode); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
if((TUint32)aCluster >= iFatEocCode) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
return ETrue; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
324 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
ASSERT((TUint32)aCluster <= iFatEocCode+7); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
return EFalse; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
329 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
/** |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
Sets "End of Cluster Chain" value in aCluster depending on the FAT type. |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
@param aCluster cluster to set to end of chain marker |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
*/ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
void CFatMountCB::SetEndOfClusterCh(TInt &aCluster) const |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
335 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
ASSERT(iFatEocCode); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
aCluster = iFatEocCode+7; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
|
0 | 341 |
//------- debug methods |
342 |
#ifdef _DEBUG |
|
343 |
/** |
|
344 |
Debug function indicates whether write fails are active or not, for test |
|
345 |
@return ETrue if write fails on or not |
|
346 |
*/ |
|
347 |
TBool CFatMountCB::IsWriteFail()const |
|
348 |
{return(iIsWriteFail);} |
|
349 |
/** |
|
350 |
Switches write fails on or off, for test |
|
351 |
@param aIsWriteFail set true or false to set write fails on or off |
|
352 |
*/ |
|
353 |
void CFatMountCB::SetWriteFail(TBool aIsWriteFail) |
|
354 |
{iIsWriteFail=aIsWriteFail;} |
|
355 |
||
356 |
/** @return number of write fails to occur, for test */ |
|
357 |
TInt CFatMountCB::WriteFailCount()const |
|
358 |
{return(iWriteFailCount);} |
|
359 |
||
360 |
/** |
|
361 |
Set the number of Write fails |
|
362 |
@param aFailCount number of write fails, for test |
|
363 |
*/ |
|
364 |
void CFatMountCB::SetWriteFailCount(TInt aFailCount) |
|
365 |
{iWriteFailCount=aFailCount;} |
|
366 |
||
367 |
/** Decrement the number of write fails, for test */ |
|
368 |
void CFatMountCB::DecWriteFailCount() |
|
369 |
{--iWriteFailCount;} |
|
370 |
||
371 |
/** @return Error for a write failure, for test */ |
|
372 |
TInt CFatMountCB::WriteFailError()const |
|
373 |
{return iWriteFailError;} |
|
374 |
||
375 |
/** |
|
376 |
Set the write fail error code, for test |
|
377 |
@param aErrorValue The Error for a write fails |
|
378 |
*/ |
|
379 |
void CFatMountCB::SetWriteFailError(TInt aErrorValue) |
|
380 |
{iWriteFailError=aErrorValue;} |
|
381 |
||
382 |
#endif |
|
383 |
||
384 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
386 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
|
0 | 388 |
//--------------------------------------------------------------------------------------------------------------------------------- |
389 |
// class CFatFormatCB |
|
390 |
||
391 |
/** @return pointer to the owning mount object */ |
|
392 |
CFatMountCB& CFatFormatCB::FatMount() |
|
393 |
{return *(CFatMountCB*)&Mount();} |
|
394 |
||
395 |
/** |
|
396 |
Returns the local drive used by the file systems from the owning mount |
|
397 |
@return Pointer to the local drive |
|
398 |
*/ |
|
399 |
CProxyDrive* CFatFormatCB::LocalDrive() |
|
400 |
{return(FatMount().LocalDrive());} |
|
401 |
||
402 |
||
403 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
404 |
// class CFatFileCB |
|
405 |
||
406 |
/** |
|
407 |
Returns the owning mount from file object |
|
408 |
||
409 |
@return pointer to the owning mount object |
|
410 |
*/ |
|
411 |
CFatMountCB& CFatFileCB::FatMount() const |
|
412 |
{return((CFatMountCB&)Mount());} |
|
413 |
||
414 |
/** |
|
415 |
Returns the fat table used by the file system for this mount |
|
416 |
||
417 |
@return Refrence to the Fat table owned by the mount |
|
418 |
*/ |
|
419 |
CFatTable& CFatFileCB::FAT() |
|
420 |
{return(FatMount().FAT());} |
|
421 |
||
422 |
/** |
|
423 |
Position with in a cluster for a given address |
|
424 |
||
425 |
@param aPos Byte position |
|
426 |
*/ |
|
427 |
TInt CFatFileCB::ClusterRelativePos(TInt aPos) |
|
428 |
{return(FatMount().ClusterRelativePos(aPos));} |
|
429 |
/** |
|
430 |
Returns Log2 of cluster size from mount |
|
431 |
||
432 |
@return cluster size |
|
433 |
*/ |
|
434 |
TInt CFatFileCB::ClusterSizeLog2() |
|
435 |
{return(FatMount().ClusterSizeLog2());} |
|
436 |
||
437 |
/* |
|
438 |
Note: this replaces SeekIndex() which was only used in sl_mnt |
|
439 |
to verify whether the seek index had been created/initialised |
|
440 |
*/ |
|
441 |
inline TBool CFatFileCB::IsSeekIndex() const |
|
442 |
{return (iSeekIndex==NULL?(TBool)EFalse:(TBool)ETrue); } |
|
443 |
||
444 |
||
445 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
446 |
// class CFatDirCB |
|
447 |
||
448 |
/** |
|
449 |
Returns the owning mount from directory object |
|
450 |
||
451 |
@return pointer to the owning mount object |
|
452 |
*/ |
|
453 |
CFatMountCB& CFatDirCB::FatMount() |
|
454 |
{return((CFatMountCB&)Mount());} |
|
455 |
||
456 |
||
457 |
||
458 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
459 |
// class CFatTable |
|
460 |
||
461 |
TUint32 CFatTable::FreeClusters() const |
|
462 |
{ |
|
463 |
return iFreeClusters; |
|
464 |
} |
|
465 |
||
466 |
||
467 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
468 |
||
469 |
inline TFatType CFatTable::FatType() const |
|
470 |
{ |
|
471 |
return iFatType; |
|
472 |
} |
|
473 |
||
474 |
inline TBool CFatTable::IsFat12() const |
|
475 |
{ |
|
476 |
return iFatType == EFat12; |
|
477 |
} |
|
478 |
||
479 |
inline TBool CFatTable::IsFat16() const |
|
480 |
{ |
|
481 |
return iFatType == EFat16; |
|
482 |
} |
|
483 |
||
484 |
inline TBool CFatTable::IsFat32() const |
|
485 |
{ |
|
486 |
return iFatType == EFat32; |
|
487 |
} |
|
488 |
||
489 |
||
490 |
/** |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
491 |
Checks for "EOC" for all Fat types |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
@param aCluster FAT table entry (cluster number) to check |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
493 |
@return ETrue if aCluster is a EOC for the FAT type being used by CFatMountCB that owns the CFatTable |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
*/ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
inline TBool CFatTable::IsEndOfClusterCh(TUint32 aCluster) const |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
{ |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
ASSERT(iFatEocCode); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
if(aCluster >= iFatEocCode) |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
return ETrue; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
ASSERT((TUint32)aCluster <= iFatEocCode+7); |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
return EFalse; |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
} |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
505 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
506 |
|
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
/** |
0 | 508 |
@return Maximal number of addresable FAT entries. This value is taken from the owning mount |
509 |
*/ |
|
510 |
inline TUint32 CFatTable::MaxEntries() const |
|
511 |
{ |
|
512 |
ASSERT(iMaxEntries > 0); |
|
513 |
return iMaxEntries; |
|
514 |
} |
|
515 |
||
516 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
517 |
// class TDriveInterface |
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
518 |
TBool TDriveInterface::NotifyUser() const |
0 | 519 |
{return(iMount->GetNotifyUser());} |
520 |
||
521 |
||
522 |
//---------------------------------------------------------------------------------------------------- |
|
523 |
// class CRawDisk |
|
524 |
||
525 |
/** |
|
526 |
Get pointer to the directory cache interface. Any client that reads/writes directory entries |
|
527 |
MUST do it via this interface. |
|
528 |
Default implementation returns NULL |
|
529 |
||
530 |
@return pointer to the MWTCacheInterface interface, or NULL if it is not present. |
|
531 |
*/ |
|
532 |
MWTCacheInterface* CRawDisk::DirCacheInterface() |
|
533 |
{ |
|
534 |
return NULL; |
|
535 |
} |
|
536 |
||
537 |
//--------------------------------------------------------------------------------------------------------------------------------- |
|
538 |
//-- class RBitVector |
|
539 |
||
540 |
/** @return size of the vector (number of bits) */ |
|
541 |
inline TUint32 RBitVector::Size() const |
|
542 |
{ |
|
543 |
return iNumBits; |
|
544 |
} |
|
545 |
||
546 |
/** |
|
547 |
Get a bit by index |
|
548 |
||
549 |
@param aIndex index in a bit vector |
|
550 |
@return 0 if the bit at pos aIndex is 0, not zero otherwise |
|
551 |
@panic EIndexOutOfRange if aIndex is out of range |
|
552 |
*/ |
|
553 |
inline TBool RBitVector::operator[](TUint32 aIndex) const |
|
554 |
{ |
|
555 |
__ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
556 |
return (ipData[WordNum(aIndex)] & (1<<BitInWord(aIndex))); |
|
557 |
} |
|
558 |
||
559 |
/** |
|
560 |
Set a bit at pos aIndex to '1' |
|
561 |
@param aIndex index in a bit vector |
|
562 |
@panic EIndexOutOfRange if aIndex is out of range |
|
563 |
*/ |
|
564 |
inline void RBitVector::SetBit(TUint32 aIndex) |
|
565 |
{ |
|
566 |
__ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
567 |
ipData[WordNum(aIndex)] |= (1<<BitInWord(aIndex)); |
|
568 |
} |
|
569 |
||
570 |
/** |
|
571 |
Set a bit at pos aIndex to '0' |
|
572 |
@param aIndex index in a bit vector |
|
573 |
@panic EIndexOutOfRange if aIndex is out of range |
|
574 |
*/ |
|
575 |
inline void RBitVector::ResetBit(TUint32 aIndex) |
|
576 |
{ |
|
577 |
__ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
578 |
ipData[WordNum(aIndex)] &= ~(1<<BitInWord(aIndex)); |
|
579 |
} |
|
580 |
||
581 |
/** |
|
582 |
Invert a bit at pos aIndex |
|
583 |
@param aIndex index in a bit vector |
|
584 |
@panic EIndexOutOfRange if aIndex is out of range |
|
585 |
*/ |
|
586 |
inline void RBitVector::InvertBit(TUint32 aIndex) |
|
587 |
{ |
|
588 |
__ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
589 |
ipData[WordNum(aIndex)] ^= (1<<BitInWord(aIndex)); |
|
590 |
} |
|
591 |
||
592 |
/** |
|
593 |
Set bit value at position aIndex |
|
594 |
@param aIndex index in a bit vector |
|
595 |
@panic EIndexOutOfRange if aIndex is out of range |
|
596 |
*/ |
|
597 |
inline void RBitVector::SetBitVal(TUint32 aIndex, TBool aVal) |
|
598 |
{ |
|
599 |
if(aVal) |
|
600 |
SetBit(aIndex); |
|
601 |
else |
|
602 |
ResetBit(aIndex); |
|
603 |
} |
|
604 |
||
605 |
||
606 |
inline TUint32 RBitVector::MaskLastWord(TUint32 aVal) const |
|
607 |
{ |
|
608 |
const TUint32 shift = (32-(iNumBits & 0x1F)) & 0x1F; |
|
609 |
return (aVal << shift) >> shift; //-- mask unused high bits |
|
610 |
} |
|
611 |
||
612 |
||
613 |
||
614 |
inline TUint32 RBitVector::WordNum(TUint32 aBitPos) const |
|
615 |
{ |
|
616 |
return aBitPos >> 5; |
|
617 |
} |
|
618 |
||
619 |
inline TUint32 RBitVector::BitInWord(TUint32 aBitPos) const |
|
620 |
{ |
|
621 |
return aBitPos & 0x1F; |
|
622 |
} |
|
623 |
||
624 |
/** |
|
625 |
Calculate offset of the page starting position in the cluster |
|
626 |
@param aPos the current entry position in bytes in the cluster |
|
627 |
@param aPageSzLog2 page size in log2 |
|
628 |
@return the starting position of the page that contains aPos |
|
629 |
*/ |
|
630 |
inline TUint32 CalculatePageOffsetInCluster(TUint32 aPos, TUint aPageSzLog2) |
|
631 |
{ |
|
632 |
return (aPos >> aPageSzLog2) << aPageSzLog2; |
|
633 |
} |
|
634 |
||
635 |
#endif //SL_STD_INL |
|
636 |
||
637 |
||
638 |
||
639 |
||
640 |