251 __PRINT3(_L("#- CFatMountCB::SetState() drv:%d, %d->%d\n"),DriveNumber(),iState,aState); |
236 __PRINT3(_L("#- CFatMountCB::SetState() drv:%d, %d->%d\n"),DriveNumber(),iState,aState); |
252 iState = aState; |
237 iState = aState; |
253 } |
238 } |
254 |
239 |
255 |
240 |
256 TFatDriveInterface& CFatMountCB::DriveInterface() const |
241 TDriveInterface& CFatMountCB::DriveInterface() const |
257 { |
242 { |
258 return (TFatDriveInterface&)iDriverInterface; |
243 return (TDriveInterface&)iDriverInterface; |
259 } |
244 } |
260 |
245 |
261 const TFatConfig& CFatMountCB::FatConfig() const |
246 const TFatConfig& CFatMountCB::FatConfig() const |
262 { |
247 { |
263 return iFatConfig; |
248 return iFatConfig; |
320 Set condition if position of new entries has been found. |
305 Set condition if position of new entries has been found. |
321 */ |
306 */ |
322 void CFatMountCB::XFileCreationHelper::SetIsNewEntryPosFound(TBool aFound) |
307 void CFatMountCB::XFileCreationHelper::SetIsNewEntryPosFound(TBool aFound) |
323 { |
308 { |
324 isNewEntryPosFound = aFound; |
309 isNewEntryPosFound = aFound; |
|
310 } |
|
311 |
|
312 |
|
313 /** |
|
314 Checks for "EOC" for all Fat types |
|
315 @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 |
|
317 */ |
|
318 TBool CFatMountCB::IsEndOfClusterCh(TInt aCluster) const |
|
319 { |
|
320 ASSERT(iFatEocCode); |
|
321 |
|
322 if((TUint32)aCluster >= iFatEocCode) |
|
323 return ETrue; |
|
324 |
|
325 ASSERT((TUint32)aCluster <= iFatEocCode+7); |
|
326 |
|
327 return EFalse; |
|
328 } |
|
329 |
|
330 /** |
|
331 Sets "End of Cluster Chain" value in aCluster depending on the FAT type. |
|
332 @param aCluster cluster to set to end of chain marker |
|
333 */ |
|
334 void CFatMountCB::SetEndOfClusterCh(TInt &aCluster) const |
|
335 { |
|
336 ASSERT(iFatEocCode); |
|
337 aCluster = iFatEocCode+7; |
325 } |
338 } |
326 |
339 |
327 |
340 |
328 //------- debug methods |
341 //------- debug methods |
329 #ifdef _DEBUG |
342 #ifdef _DEBUG |
367 {iWriteFailError=aErrorValue;} |
380 {iWriteFailError=aErrorValue;} |
368 |
381 |
369 #endif |
382 #endif |
370 |
383 |
371 |
384 |
|
385 |
|
386 |
|
387 |
372 //--------------------------------------------------------------------------------------------------------------------------------- |
388 //--------------------------------------------------------------------------------------------------------------------------------- |
373 // class CFatFormatCB |
389 // class CFatFormatCB |
374 |
390 |
375 /** @return pointer to the owning mount object */ |
391 /** @return pointer to the owning mount object */ |
376 CFatMountCB& CFatFormatCB::FatMount() |
392 CFatMountCB& CFatFormatCB::FatMount() |
445 TUint32 CFatTable::FreeClusters() const |
461 TUint32 CFatTable::FreeClusters() const |
446 { |
462 { |
447 return iFreeClusters; |
463 return iFreeClusters; |
448 } |
464 } |
449 |
465 |
450 TBool CFatTable::IsEof32Bit(TInt aCluster) const |
|
451 {return(aCluster>=(TInt)0x0FFFFFF8 && aCluster<=(TInt)0x0FFFFFFF);} |
|
452 |
|
453 TBool CFatTable::IsEof16Bit(TInt aCluster) const |
|
454 {return(aCluster>=0xFFF8 && aCluster<=0xFFFF);} |
|
455 |
|
456 TBool CFatTable::IsEof12Bit(TInt aCluster) const |
|
457 {return(aCluster>=0xFF8 && aCluster<=0xFFF);} |
|
458 |
|
459 TInt CFatTable::SectorSizeLog2() const |
|
460 {return(iOwner->SectorSizeLog2());} |
|
461 |
466 |
462 //--------------------------------------------------------------------------------------------------------------------------------- |
467 //--------------------------------------------------------------------------------------------------------------------------------- |
463 |
468 |
464 inline TFatType CFatTable::FatType() const |
469 inline TFatType CFatTable::FatType() const |
465 { |
470 { |
477 } |
482 } |
478 |
483 |
479 inline TBool CFatTable::IsFat32() const |
484 inline TBool CFatTable::IsFat32() const |
480 { |
485 { |
481 return iFatType == EFat32; |
486 return iFatType == EFat32; |
|
487 } |
|
488 |
|
489 |
|
490 /** |
|
491 Checks for "EOC" for all Fat types |
|
492 @param aCluster FAT table entry (cluster number) to check |
|
493 @return ETrue if aCluster is a EOC for the FAT type being used by CFatMountCB that owns the CFatTable |
|
494 */ |
|
495 inline TBool CFatTable::IsEndOfClusterCh(TUint32 aCluster) const |
|
496 { |
|
497 ASSERT(iFatEocCode); |
|
498 |
|
499 if(aCluster >= iFatEocCode) |
|
500 return ETrue; |
|
501 |
|
502 ASSERT((TUint32)aCluster <= iFatEocCode+7); |
|
503 return EFalse; |
482 } |
504 } |
483 |
505 |
484 |
506 |
485 /** |
507 /** |
486 @return Maximal number of addresable FAT entries. This value is taken from the owning mount |
508 @return Maximal number of addresable FAT entries. This value is taken from the owning mount |
490 ASSERT(iMaxEntries > 0); |
512 ASSERT(iMaxEntries > 0); |
491 return iMaxEntries; |
513 return iMaxEntries; |
492 } |
514 } |
493 |
515 |
494 |
516 |
495 // class TFatDriveInterface |
517 // class TDriveInterface |
496 TBool TFatDriveInterface::NotifyUser() const |
518 TBool TDriveInterface::NotifyUser() const |
497 {return(iMount->GetNotifyUser());} |
519 {return(iMount->GetNotifyUser());} |
498 |
520 |
499 |
521 |
500 //---------------------------------------------------------------------------------------------------- |
522 //---------------------------------------------------------------------------------------------------- |
501 // class CRawDisk |
523 // class CRawDisk |
511 { |
533 { |
512 return NULL; |
534 return NULL; |
513 } |
535 } |
514 |
536 |
515 //--------------------------------------------------------------------------------------------------------------------------------- |
537 //--------------------------------------------------------------------------------------------------------------------------------- |
516 //-- class RBitVector |
|
517 |
|
518 /** @return size of the vector (number of bits) */ |
|
519 inline TUint32 RBitVector::Size() const |
|
520 { |
|
521 return iNumBits; |
|
522 } |
|
523 |
|
524 /** |
|
525 Get a bit by index |
|
526 |
|
527 @param aIndex index in a bit vector |
|
528 @return 0 if the bit at pos aIndex is 0, not zero otherwise |
|
529 @panic EIndexOutOfRange if aIndex is out of range |
|
530 */ |
|
531 inline TBool RBitVector::operator[](TUint32 aIndex) const |
|
532 { |
|
533 __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
534 return (ipData[WordNum(aIndex)] & (1<<BitInWord(aIndex))); |
|
535 } |
|
536 |
|
537 /** |
|
538 Set a bit at pos aIndex to '1' |
|
539 @param aIndex index in a bit vector |
|
540 @panic EIndexOutOfRange if aIndex is out of range |
|
541 */ |
|
542 inline void RBitVector::SetBit(TUint32 aIndex) |
|
543 { |
|
544 __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
545 ipData[WordNum(aIndex)] |= (1<<BitInWord(aIndex)); |
|
546 } |
|
547 |
|
548 /** |
|
549 Set a bit at pos aIndex to '0' |
|
550 @param aIndex index in a bit vector |
|
551 @panic EIndexOutOfRange if aIndex is out of range |
|
552 */ |
|
553 inline void RBitVector::ResetBit(TUint32 aIndex) |
|
554 { |
|
555 __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
556 ipData[WordNum(aIndex)] &= ~(1<<BitInWord(aIndex)); |
|
557 } |
|
558 |
|
559 /** |
|
560 Invert a bit at pos aIndex |
|
561 @param aIndex index in a bit vector |
|
562 @panic EIndexOutOfRange if aIndex is out of range |
|
563 */ |
|
564 inline void RBitVector::InvertBit(TUint32 aIndex) |
|
565 { |
|
566 __ASSERT_ALWAYS(aIndex < iNumBits, Panic(EIndexOutOfRange)); |
|
567 ipData[WordNum(aIndex)] ^= (1<<BitInWord(aIndex)); |
|
568 } |
|
569 |
|
570 /** |
|
571 Set bit value at position aIndex |
|
572 @param aIndex index in a bit vector |
|
573 @panic EIndexOutOfRange if aIndex is out of range |
|
574 */ |
|
575 inline void RBitVector::SetBitVal(TUint32 aIndex, TBool aVal) |
|
576 { |
|
577 if(aVal) |
|
578 SetBit(aIndex); |
|
579 else |
|
580 ResetBit(aIndex); |
|
581 } |
|
582 |
|
583 |
|
584 inline TUint32 RBitVector::MaskLastWord(TUint32 aVal) const |
|
585 { |
|
586 const TUint32 shift = (32-(iNumBits & 0x1F)) & 0x1F; |
|
587 return (aVal << shift) >> shift; //-- mask unused high bits |
|
588 } |
|
589 |
|
590 |
|
591 |
|
592 inline TUint32 RBitVector::WordNum(TUint32 aBitPos) const |
|
593 { |
|
594 return aBitPos >> 5; |
|
595 } |
|
596 |
|
597 inline TUint32 RBitVector::BitInWord(TUint32 aBitPos) const |
|
598 { |
|
599 return aBitPos & 0x1F; |
|
600 } |
|
601 |
538 |
602 /** |
539 /** |
603 Calculate offset of the page starting position in the cluster |
540 Calculate offset of the page starting position in the cluster |
604 @param aPos the current entry position in bytes in the cluster |
541 @param aPos the current entry position in bytes in the cluster |
605 @param aPageSzLog2 page size in log2 |
542 @param aPageSzLog2 page size in log2 |