userlibandfileserver/fileserver/sfat32/fat_table32.cpp
changeset 33 0173bcd7697c
parent 0 a41df078684a
child 36 538db54a451d
--- a/userlibandfileserver/fileserver/sfat32/fat_table32.cpp	Wed Dec 23 11:43:31 2009 +0000
+++ b/userlibandfileserver/fileserver/sfat32/fat_table32.cpp	Thu Jan 07 13:38:45 2010 +0200
@@ -33,14 +33,14 @@
 //---------------------------------------------------------------------------------------------------------------------------------------
 /** 
     Implements automatic locking object.
-    Calls TFatDriveInterface::AcquireLock() on construction and TFatDriveInterface::ReleaseLock() on destruction. 
+    Calls TDriveInterface::AcquireLock() on construction and TDriveInterface::ReleaseLock() on destruction. 
     Can be constructed on the stack only.
 */
 class XAutoLock
     {
      public:
        inline XAutoLock(CFatMountCB* apOwner) : iDrv(apOwner->DriveInterface()) {iDrv.AcquireLock();}
-       inline XAutoLock(TFatDriveInterface& aDrv) : iDrv(aDrv) {iDrv.AcquireLock();}
+       inline XAutoLock(TDriveInterface& aDrv) : iDrv(aDrv) {iDrv.AcquireLock();}
        inline ~XAutoLock() {iDrv.ReleaseLock();}
 
      private:
@@ -48,7 +48,7 @@
         void* operator new(TUint, void*);
 
      private:
-        TFatDriveInterface &iDrv; ///< reference to the drive interface
+        TDriveInterface &iDrv; ///< reference to the drive interface
     };
 
 
@@ -126,6 +126,12 @@
     iFatType = iOwner->FatType();
     ASSERT(IsFat12() || IsFat16() || IsFat32());
 
+    //-- set the EOC code
+    iFatEocCode = EocCodeByFatType(iFatType);
+    
+
+
+
     iFreeClusterHint = KFatFirstSearchCluster;
 
     //-- cache the media attributes
@@ -1732,42 +1738,21 @@
     Get the next cluster in the chain from the FAT
 
     @param aCluster number to read, contains next cluster upon return
-    @leave
     @return False if end of cluster chain
 */
 TBool CFatTable::GetNextClusterL(TInt& aCluster) const
     {
 	__PRINT1(_L("CAtaFatTable::GetNextClusterL(%d)"), aCluster);
     
-    const TInt nextCluster = ReadL(aCluster);
-    TBool ret = EFalse; 
+    const TUint32 nextCluster = ReadL(aCluster);
+    const TBool bEOC = IsEndOfClusterCh(nextCluster);
+
+    if(bEOC) 
+        return EFalse; //-- the end of cluster chain
+
+    aCluster = nextCluster;
     
-    switch(FatType())
-        {
-        case EFat12:
-            ret=!IsEof12Bit(nextCluster);
-        break;
-
-        case EFat16:
-            ret=!IsEof16Bit(nextCluster);
-        break;
-
-        case EFat32:
-            ret=!IsEof32Bit(nextCluster);
-        break;
-
-        default:
-            ASSERT(0);
-            return EFalse;//-- get rid of warning
-        };
-	
-    if (ret)
-        {
-		aCluster=nextCluster;
-	    }
-
-    return ret;
-
+    return ETrue;    
     }
 
 /**