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