36 { |
36 { |
37 ASSERT(this != &aRhs); |
37 ASSERT(this != &aRhs); |
38 return (iCluster == aRhs.iCluster && iPos == aRhs.iPos); |
38 return (iCluster == aRhs.iCluster && iPos == aRhs.iPos); |
39 } |
39 } |
40 |
40 |
|
41 /** set "end of directory" indicator*/ |
|
42 void TEntryPos::SetEndOfDir() |
|
43 { |
|
44 iCluster = EOF_32Bit; |
|
45 } |
|
46 |
41 |
47 |
42 //--------------------------------------------------------------------------------------------------------------------------------- |
48 //--------------------------------------------------------------------------------------------------------------------------------- |
43 // class CFatMountCB |
49 // class CFatMountCB |
44 |
50 |
45 inline TInt CFatMountCB::RootDirectorySector() const |
51 |
46 {return iVolParam.RootDirectorySector();} |
52 /** @return ETrue if the value of aClusterNo is valid*/ |
47 |
53 inline TBool CFatMountCB::ClusterNumberValid(TUint32 aClusterNo) const |
48 inline TUint CFatMountCB::RootDirEnd() const |
54 { |
49 {return iVolParam.RootDirEnd();} |
55 ASSERT(ConsistentState()); |
|
56 |
|
57 if(!aClusterNo && !Is32BitFat()) |
|
58 return ETrue; //-- root dir. cluster for FAT12/16 |
|
59 |
|
60 return (aClusterNo >= KFatFirstSearchCluster) && (aClusterNo < UsableClusters()+KFatFirstSearchCluster); |
|
61 } |
|
62 |
|
63 |
|
64 inline TUint32 CFatMountCB::RootDirectorySector() const |
|
65 { |
|
66 return iVolParam.RootDirectorySector(); |
|
67 } |
|
68 |
|
69 inline TUint32 CFatMountCB::RootDirEnd() const |
|
70 { |
|
71 return iVolParam.RootDirEnd(); |
|
72 } |
50 |
73 |
51 inline TUint32 CFatMountCB::RootClusterNum() const |
74 inline TUint32 CFatMountCB::RootClusterNum() const |
52 {return iVolParam.RootClusterNum(); } |
75 { |
53 |
76 return iVolParam.RootClusterNum(); |
54 |
77 } |
55 inline TInt CFatMountCB::StartCluster(const TFatDirEntry & anEntry) const |
78 |
|
79 |
|
80 inline TUint32 CFatMountCB::StartCluster(const TFatDirEntry & anEntry) const |
56 { |
81 { |
57 if(Is32BitFat()) |
82 if(Is32BitFat()) |
58 return anEntry.StartCluster(); |
83 return anEntry.StartCluster(); |
59 else |
84 else |
60 return 0xFFFF&anEntry.StartCluster(); |
85 return anEntry.StartCluster() & 0xFFFF; |
61 } |
86 } |
62 |
87 |
63 /** |
88 /** |
64 returns true for root dir on Fat12/16 (fixed root dir versions of Fat) false on fat32 |
89 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. |
90 this function is used to handle special cases for reading/writing the root directory on FAT via the use of cluster zero. |
66 |
91 |
67 @param aEntry position on volume being queried |
92 @param entryPos directory entry position |
68 @return Whether Root dir position or not |
93 @return ETrue if entryPos belongs to the FAT12/16 root directory |
69 */ |
94 */ |
70 TBool CFatMountCB::IsRootDir(const TEntryPos &aEntry) const |
95 TBool CFatMountCB::IsRootDir(const TEntryPos &entryPos) const |
71 { |
96 { |
72 if(Is32BitFat()) |
97 //-- for FAT12/16 cluster 0 means "root directory" |
73 return EFalse; |
98 return !(Is32BitFat() || entryPos.iCluster); |
74 else |
|
75 return((aEntry.iCluster==0) ? (TBool)ETrue : (TBool)EFalse); |
|
76 } |
99 } |
77 /** |
100 /** |
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 |
101 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 |
102 @return The root cluster indicator |
80 */ |
103 */ |
81 TInt CFatMountCB::RootIndicator() const |
104 TUint32 CFatMountCB::RootIndicator() const |
82 { |
105 { |
83 if(Is32BitFat()) |
106 if(Is32BitFat()) |
84 return iVolParam.RootClusterNum(); |
107 return iVolParam.RootClusterNum(); |
85 else |
108 else |
86 return 0; |
109 return 0; |
87 } |
110 } |
88 |
111 |
89 |
112 |
90 /** @return Log2 of cluster size on volume */ |
113 /** @return Log2 of cluster size on volume */ |
91 TInt CFatMountCB::ClusterSizeLog2() const |
114 TUint32 CFatMountCB::ClusterSizeLog2() const |
92 {return(iVolParam.ClusterSizeLog2());} |
115 { |
|
116 return(iVolParam.ClusterSizeLog2()); |
|
117 } |
93 |
118 |
94 /** @return Log2 of media sector size */ |
119 /** @return Log2 of media sector size */ |
95 TInt CFatMountCB::SectorSizeLog2() const |
120 TUint32 CFatMountCB::SectorSizeLog2() const |
96 {return(iVolParam.SectorSizeLog2());} |
121 { |
|
122 return(iVolParam.SectorSizeLog2()); |
|
123 } |
97 |
124 |
98 /** @return sector per cluster */ |
125 /** @return sector per cluster */ |
99 TInt CFatMountCB::SectorsPerCluster() const |
126 TUint32 CFatMountCB::SectorsPerCluster() const |
100 {return(1<<(iVolParam.ClusterSizeLog2()-iVolParam.SectorSizeLog2()));} |
127 { |
|
128 return(1<<(iVolParam.ClusterSizeLog2()-iVolParam.SectorSizeLog2())); |
|
129 } |
101 |
130 |
102 /** @return the base position of a cluster */ |
131 /** @return the base position of a cluster */ |
103 TInt CFatMountCB::ClusterBasePosition() const |
132 TUint32 CFatMountCB::ClusterBasePosition() const |
104 {return(iFirstFreeByte);} |
133 { |
|
134 return(iFirstFreeByte); |
|
135 } |
105 |
136 |
106 /** @return the offset into a cluster of a byte address */ |
137 /** @return the offset into a cluster of a byte address */ |
107 TInt CFatMountCB::ClusterRelativePos(TInt aPos) const |
138 TUint32 CFatMountCB::ClusterRelativePos(TUint32 aPos) const |
108 {return(aPos&((1<<ClusterSizeLog2())-1));} |
139 { |
|
140 return(aPos & ((1<<ClusterSizeLog2())-1)); |
|
141 } |
109 |
142 |
110 /** |
143 /** |
111 Calculates the maximum number of clusters |
144 Calculates the maximum number of clusters |
112 @return maximum number of clusters |
145 @return maximum number of clusters |
113 */ |
146 */ |
114 TUint32 CFatMountCB::MaxClusterNumber() const |
147 TUint32 CFatMountCB::MaxClusterNumber() const |
115 {return(TotalSectors()>>(ClusterSizeLog2()-SectorSizeLog2()));} |
148 {return(TotalSectors()>>(ClusterSizeLog2()-SectorSizeLog2()));} |
116 |
149 |
117 /** @return the the total sectors on volume */ |
150 /** @return the the total sectors on volume */ |
118 TInt CFatMountCB::TotalSectors() const |
151 TUint32 CFatMountCB::TotalSectors() const |
119 {return iVolParam.TotalSectors();} |
152 { |
|
153 return iVolParam.TotalSectors(); |
|
154 } |
120 |
155 |
121 /** @return total size of a Fat in bytes */ |
156 /** @return total size of a Fat in bytes */ |
122 TInt CFatMountCB::FatSizeInBytes() const |
157 TUint32 CFatMountCB::FatSizeInBytes() const |
123 {return iVolParam.FatSizeInBytes();} |
158 { |
|
159 return iVolParam.FatSizeInBytes(); |
|
160 } |
124 |
161 |
125 /** @return first sector of the Fat */ |
162 /** @return first sector of the Fat */ |
126 TUint32 CFatMountCB::FirstFatSector() const |
163 TUint32 CFatMountCB::FirstFatSector() const |
127 {return iVolParam.FirstFatSector();} |
164 { |
|
165 return iVolParam.FirstFatSector(); |
|
166 } |
128 |
167 |
129 /** @return the byte offset of the Fat */ |
168 /** @return the byte offset of the Fat */ |
130 TInt CFatMountCB::StartOfFatInBytes() const |
169 TUint32 CFatMountCB::StartOfFatInBytes() const |
131 {return(FirstFatSector()<<SectorSizeLog2());} |
170 { |
|
171 return(FirstFatSector()<<SectorSizeLog2()); |
|
172 } |
132 |
173 |
133 /** @return Number of Fats used by the volume */ |
174 /** @return Number of Fats used by the volume */ |
134 TInt CFatMountCB::NumberOfFats() const |
175 TUint32 CFatMountCB::NumberOfFats() const |
135 {return iVolParam.NumberOfFats();} |
176 { |
|
177 return iVolParam.NumberOfFats(); |
|
178 } |
136 |
179 |
137 |
180 |
138 /** @return refrence to the fat table owned by the mount */ |
181 /** @return refrence to the fat table owned by the mount */ |
139 CFatTable& CFatMountCB::FAT() const |
182 CFatTable& CFatMountCB::FAT() const |
140 {return(*iFatTable);} |
183 { |
|
184 return(*iFatTable); |
|
185 } |
|
186 |
141 /** |
187 /** |
142 @return refrence to the file system object that has produced this CFatMountCB |
188 @return refrence to the file system object that has produced this CFatMountCB |
143 */ |
189 */ |
144 CFatFileSystem& CFatMountCB::FatFileSystem() const |
190 CFatFileSystem& CFatMountCB::FatFileSystem() const |
145 { |
191 { |
152 {return(*iRawDisk);} |
198 {return(*iRawDisk);} |
153 |
199 |
154 /** |
200 /** |
155 @return ETrue if aCluster value is bad cluster marker defined in FAT specification |
201 @return ETrue if aCluster value is bad cluster marker defined in FAT specification |
156 */ |
202 */ |
157 TBool CFatMountCB::IsBadCluster(TInt aCluster) const |
203 TBool CFatMountCB::IsBadCluster(TUint32 aCluster) const |
158 {return Is32BitFat() ? aCluster==0xFFFFFF7 : Is16BitFat() ? aCluster==0xFFF7 : aCluster==0xFF7;} |
204 { |
|
205 return Is32BitFat() ? aCluster==0xFFFFFF7 : Is16BitFat() ? aCluster==0xFFF7 : aCluster==0xFF7; |
|
206 } |
159 |
207 |
160 /** |
208 /** |
161 Returns whether the current mount is running as rugged Fat or not, this is held in the file system object |
209 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 |
210 @return ETrue if this is Rugged FAT |
163 */ |
211 */ |
164 TBool CFatMountCB::IsRuggedFSys() const |
212 TBool CFatMountCB::IsRuggedFSys() const |
165 {return Drive().IsRugged();} |
213 { |
|
214 return Drive().IsRugged(); |
|
215 } |
166 |
216 |
167 /** |
217 /** |
168 Sets the rugged flag in the file system object |
218 Sets the rugged flag in the file system object |
169 @param Flag to set or clear the rugged flag |
219 @param Flag to set or clear the rugged flag |
170 */ |
220 */ |
171 void CFatMountCB::SetRuggedFSys(TBool aVal) |
221 void CFatMountCB::SetRuggedFSys(TBool aVal) |
172 {Drive().SetRugged(aVal);} |
222 { |
|
223 Drive().SetRugged(aVal); |
|
224 } |
|
225 |
|
226 /** |
|
227 @return Log2(Media atomic write granularity). |
|
228 This is mostly to be used in Rugged FAT mode, see IsRuggedFSys(). For Rugged FAT the media shall support atomic writes. |
|
229 By default this is the sector (512 bytes) |
|
230 |
|
231 */ |
|
232 TUint32 CFatMountCB::AtomicWriteGranularityLog2() const |
|
233 { |
|
234 return KDefSectorSzLog2; |
|
235 } |
|
236 |
173 |
237 |
174 /** @return the usable clusters count for a volume */ |
238 /** @return the usable clusters count for a volume */ |
175 TUint32 CFatMountCB::UsableClusters() const |
239 TUint32 CFatMountCB::UsableClusters() const |
176 {return(iUsableClusters);} |
240 { |
177 |
241 return(iUsableClusters); |
178 |
242 } |
179 TUint CFatMountCB::StartOfRootDirInBytes() const |
243 |
180 {return iVolParam.RootDirectorySector()<<SectorSizeLog2();} |
244 |
|
245 TUint32 CFatMountCB::StartOfRootDirInBytes() const |
|
246 { |
|
247 return iVolParam.RootDirectorySector()<<SectorSizeLog2(); |
|
248 } |
181 |
249 |
182 |
250 |
183 /** @return FAT type for this mount */ |
251 /** @return FAT type for this mount */ |
184 TFatType CFatMountCB::FatType() const |
252 TFatType CFatMountCB::FatType() const |
185 { |
253 { |
313 /** |
383 /** |
314 Checks for "EOC" for all Fat types |
384 Checks for "EOC" for all Fat types |
315 @param aCluster FAT table entry (cluster number) to check |
385 @param aCluster FAT table entry (cluster number) to check |
316 @return ETrue if aCluster is a EOC for the FAT type being used by CFatMountCB |
386 @return ETrue if aCluster is a EOC for the FAT type being used by CFatMountCB |
317 */ |
387 */ |
318 TBool CFatMountCB::IsEndOfClusterCh(TInt aCluster) const |
388 TBool CFatMountCB::IsEndOfClusterCh(TUint32 aCluster) const |
319 { |
389 { |
320 ASSERT(iFatEocCode); |
390 ASSERT(iFatEocCode); |
321 |
391 ASSERT((TUint32)aCluster <= iFatEocCode+7); //-- aCluster value is always masked accordingly. |
322 if((TUint32)aCluster >= iFatEocCode) |
392 |
323 return ETrue; |
393 return (aCluster >= iFatEocCode); |
324 |
|
325 ASSERT((TUint32)aCluster <= iFatEocCode+7); |
|
326 |
|
327 return EFalse; |
|
328 } |
394 } |
329 |
395 |
330 /** |
396 /** |
331 Sets "End of Cluster Chain" value in aCluster depending on the FAT type. |
397 Sets "End of Cluster Chain" value in aCluster depending on the FAT type. |
332 @param aCluster cluster to set to end of chain marker |
398 @param aCluster cluster to set to end of chain marker |
333 */ |
399 */ |
334 void CFatMountCB::SetEndOfClusterCh(TInt &aCluster) const |
400 void CFatMountCB::SetEndOfClusterCh(TUint32 &aCluster) const |
335 { |
401 { |
336 ASSERT(iFatEocCode); |
402 ASSERT(iFatEocCode); |
337 aCluster = iFatEocCode+7; |
403 aCluster = iFatEocCode+7; |
338 } |
404 } |
|
405 |
|
406 |
|
407 CFatMountCB::TEntrySetChunkInfo::TEntrySetChunkInfo() |
|
408 :iNumEntries(KMaxTUint) |
|
409 { |
|
410 } |
|
411 |
|
412 |
|
413 TBool CFatMountCB::TEntrySetChunkInfo::operator==(const TEntrySetChunkInfo& aRhs) |
|
414 { |
|
415 ASSERT(&aRhs != this); |
|
416 return (iNumEntries == aRhs.iNumEntries) && (iEntryPos==aRhs.iEntryPos); |
|
417 } |
|
418 |
|
419 |
339 |
420 |
340 |
421 |
341 //------- debug methods |
422 //------- debug methods |
342 #ifdef _DEBUG |
423 #ifdef _DEBUG |
343 /** |
424 /** |
432 @return cluster size |
513 @return cluster size |
433 */ |
514 */ |
434 TInt CFatFileCB::ClusterSizeLog2() |
515 TInt CFatFileCB::ClusterSizeLog2() |
435 {return(FatMount().ClusterSizeLog2());} |
516 {return(FatMount().ClusterSizeLog2());} |
436 |
517 |
437 /* |
518 |
438 Note: this replaces SeekIndex() which was only used in sl_mnt |
519 //--------------------------------------------------------------------------------------------------------------------------------- |
439 to verify whether the seek index had been created/initialised |
520 TBool CFatFileCB::FileSizeModified() const |
440 */ |
521 { |
441 inline TBool CFatFileCB::IsSeekIndex() const |
522 return iFileSizeModified; |
442 {return (iSeekIndex==NULL?(TBool)EFalse:(TBool)ETrue); } |
523 } |
|
524 |
|
525 void CFatFileCB::IndicateFileSizeModified(TBool aModified) |
|
526 { |
|
527 iFileSizeModified = aModified; |
|
528 } |
|
529 |
|
530 //----------------------------------------------------------------------------- |
|
531 /** @return ETrue if file attributes' 'Modified' flag is set*/ |
|
532 TBool CFatFileCB::FileAttModified() const |
|
533 { |
|
534 return (Att() & KEntryAttModified); |
|
535 } |
|
536 |
|
537 /** |
|
538 Set or reset a flag indicating that file attributes had beed modified |
|
539 @param aModified ETrue means that attributes are modified |
|
540 */ |
|
541 |
|
542 void CFatFileCB::IndicateFileAttModified(TBool aModified) |
|
543 { |
|
544 if(aModified) |
|
545 iAtt |= KEntryAttModified; |
|
546 else |
|
547 iAtt &= ~KEntryAttModified; |
|
548 } |
|
549 |
|
550 TUint32 CFatFileCB::FCB_StartCluster() const |
|
551 { |
|
552 return iStartCluster; |
|
553 } |
|
554 |
|
555 |
|
556 void CFatFileCB::FCB_SetStartCluster(TUint32 aVal) |
|
557 { |
|
558 ASSERT(aVal == 0 || (aVal >= KFatFirstSearchCluster)); |
|
559 iStartCluster = aVal; |
|
560 } |
|
561 |
|
562 /** @return file size from CFileCB */ |
|
563 TUint32 CFatFileCB::FCB_FileSize() const |
|
564 { |
|
565 return Size(); |
|
566 } |
|
567 |
|
568 /** set file size in the CFileCB*/ |
|
569 void CFatFileCB::FCB_SetFileSize(TUint32 aVal) |
|
570 { |
|
571 SetSize(aVal); |
|
572 } |
|
573 |
|
574 TBool CFatFileCB::FileTimeModified() const |
|
575 { |
|
576 return iFileTimeModified; |
|
577 } |
|
578 |
|
579 void CFatFileCB::IndicateFileTimeModified(TBool aModified) |
|
580 { |
|
581 iFileTimeModified = aModified; |
|
582 } |
|
583 |
443 |
584 |
444 |
585 |
445 //--------------------------------------------------------------------------------------------------------------------------------- |
586 //--------------------------------------------------------------------------------------------------------------------------------- |
446 // class CFatDirCB |
587 // class CFatDirCB |
447 |
588 |