userlibandfileserver/fileserver/sfat32/sl_mnt.cpp
changeset 291 206a6eaaeb71
parent 271 dc268b18d709
equal deleted inserted replaced
289:55a0a1279a7e 291:206a6eaaeb71
  1632         {
  1632         {
  1633         ReadDirEntryL(dirEntryPos,dirEntry);
  1633         ReadDirEntryL(dirEntryPos,dirEntry);
  1634         MoveToDosEntryL(dirEntryPos,dirEntry);
  1634         MoveToDosEntryL(dirEntryPos,dirEntry);
  1635         if (dirEntry.IsParentDirectory() || dirEntry.IsCurrentDirectory())
  1635         if (dirEntry.IsParentDirectory() || dirEntry.IsCurrentDirectory())
  1636             goto LoopEnd;
  1636             goto LoopEnd;
       
  1637         
  1637         if (dirEntry.IsEndOfDirectory())
  1638         if (dirEntry.IsEndOfDirectory())
  1638             return ETrue;
  1639             return ETrue;
       
  1640         
  1639         if (IsRootDir(dirEntryPos)&&(dirEntryPos.iPos+StartOfRootDirInBytes()==RootDirEnd()))
  1641         if (IsRootDir(dirEntryPos)&&(dirEntryPos.iPos+StartOfRootDirInBytes()==RootDirEnd()))
  1640             return ETrue;   //  Root Directory has no end of directory marker
  1642             return ETrue;   //  Root Directory has no end of directory marker
       
  1643         
  1641         if (!dirEntry.IsErased())
  1644         if (!dirEntry.IsErased())
  1642             return EFalse;
  1645             break; //-- found a valid dir. entry
  1643 LoopEnd:
  1646 LoopEnd:
  1644         MoveToNextEntryL(dirEntryPos);
  1647         MoveToNextEntryL(dirEntryPos);
  1645         }
  1648         }
       
  1649     
       
  1650     return EFalse;
  1646     }
  1651     }
  1647 
  1652 
  1648 //-----------------------------------------------------------------------------------------
  1653 //-----------------------------------------------------------------------------------------
  1649 
  1654 
  1650 /**
  1655 /**
  1808         __ASSERT_ALWAYS(aPos.iPos>startPos,User::Leave(KErrCorrupt));
  1813         __ASSERT_ALWAYS(aPos.iPos>startPos,User::Leave(KErrCorrupt));
  1809         previouscluster=aPos.iCluster;
  1814         previouscluster=aPos.iCluster;
  1810         if (offset<length)
  1815         if (offset<length)
  1811             {__ASSERT_ALWAYS(FAT().GetNextClusterL(aPos.iCluster),User::Leave(KErrCorrupt));}
  1816             {__ASSERT_ALWAYS(FAT().GetNextClusterL(aPos.iCluster),User::Leave(KErrCorrupt));}
  1812         if (offset>=length)
  1817         if (offset>=length)
  1813             return;
  1818             break;
  1814         }
  1819         }
  1815     }
  1820     }
  1816 
  1821 
  1817 //-----------------------------------------------------------------------------------------
  1822 //-----------------------------------------------------------------------------------------
  1818 
  1823 
  1882         if ((offset<aLength))
  1887         if ((offset<aLength))
  1883             {
  1888             {
  1884             __ASSERT_ALWAYS(FAT().GetNextClusterL(aPos.iCluster),User::Leave(KErrCorrupt));
  1889             __ASSERT_ALWAYS(FAT().GetNextClusterL(aPos.iCluster),User::Leave(KErrCorrupt));
  1885             }
  1890             }
  1886         if (offset>=aLength)
  1891         if (offset>=aLength)
  1887             return;
  1892             break;
  1888         }
  1893         }
  1889     }
  1894     }
  1890 
  1895 
  1891 //-----------------------------------------------------------------------------------------
  1896 //-----------------------------------------------------------------------------------------
  1892 
  1897 
  3511     const TPtrC shortNameWithoutPathDelimiter(aShortName.Mid(namePos));
  3516     const TPtrC shortNameWithoutPathDelimiter(aShortName.Mid(namePos));
  3512     __ASSERT_ALWAYS(shortNameWithoutPathDelimiter.Length()<=12,User::Leave(KErrBadName));
  3517     __ASSERT_ALWAYS(shortNameWithoutPathDelimiter.Length()<=12,User::Leave(KErrBadName));
  3513 
  3518 
  3514     TLeafDirData leafDir;
  3519     TLeafDirData leafDir;
  3515     pos.iCluster=FindLeafDirL(aShortName.Left(namePos), leafDir);
  3520     pos.iCluster=FindLeafDirL(aShortName.Left(namePos), leafDir);
  3516     FOREVER
  3521     
       
  3522     for(;;)
  3517         {
  3523         {
  3518         TFatDirEntry startEntry;
  3524         TFatDirEntry startEntry;
  3519         User::LeaveIfError(GetDirEntry(pos,entry,startEntry,aLongName));
  3525         User::LeaveIfError(GetDirEntry(pos,entry,startEntry,aLongName));
  3520         if (entry.IsEndOfDirectory())
  3526         if (entry.IsEndOfDirectory())
  3521             User::Leave(KErrNotFound);
  3527             User::Leave(KErrNotFound);
  3527             TBuf8<0x20> entryName8(DosNameFromStdFormat(entry.Name()));
  3533             TBuf8<0x20> entryName8(DosNameFromStdFormat(entry.Name()));
  3528             TBuf<0x20> entryName;
  3534             TBuf<0x20> entryName;
  3529             LocaleUtils::ConvertToUnicodeL(entryName, entryName8);
  3535             LocaleUtils::ConvertToUnicodeL(entryName, entryName8);
  3530             if (shortNameWithoutPathDelimiter.MatchF(entryName)!=KErrNotFound)
  3536             if (shortNameWithoutPathDelimiter.MatchF(entryName)!=KErrNotFound)
  3531                 {
  3537                 {
  3532                 if (entryIsVFat==EFalse)
  3538                 if(!entryIsVFat)
  3533                     aLongName=shortNameWithoutPathDelimiter;
  3539                     aLongName=shortNameWithoutPathDelimiter;
  3534                 return;
  3540                 
       
  3541                 break;
  3535                 }
  3542                 }
  3536             }
  3543             }
  3537         MoveToNextEntryL(pos);
  3544         MoveToNextEntryL(pos);
  3538         }
  3545         }//for(;;)
  3539     }
  3546     }
  3540 
  3547 
  3541 
  3548 
  3542 
  3549 
  3543 //-----------------------------------------------------------------------------------------
  3550 //-----------------------------------------------------------------------------------------
  3813         local->Status() = KErrNotReady;
  3820         local->Status() = KErrNotReady;
  3814 #endif
  3821 #endif
  3815     r=local->ErasePassword();
  3822     r=local->ErasePassword();
  3816     if(r==KErrNone)
  3823     if(r==KErrNone)
  3817         {
  3824         {
  3818         // ...media change to ensure a fresh remount the drive
  3825         //-- ReMount whole driver stack since MBR may have been rewritten and partition may have moved / changed size.
  3819         r = local->ForceRemount(0);
  3826         //-- this is mostly applicable to SD cards formatting, since SD stack takes care of creating partition table.
       
  3827         //-- use KForceMediaChangeReOpenAllMediaDrivers flag that will cause remounting media 
       
  3828         //-- drivers associatied with the current partition only and not affecting other ones.
       
  3829         r = LocalDrive()->ForceRemount((TUint)RFs::KForceMediaChangeReOpenMediaDriver);
       
  3830         
  3820         local->Status() = KErrNotReady;
  3831         local->Status() = KErrNotReady;
  3821         WritePasswordData();
  3832         WritePasswordData();
  3822         }
  3833         }
  3823     return(r);
  3834     return(r);
  3824     }
  3835     }
  4364 @return The offset in seconds that timestamps on the filesystem have, relative to UTC.
  4375 @return The offset in seconds that timestamps on the filesystem have, relative to UTC.
  4365 */
  4376 */
  4366 TTimeIntervalSeconds CFatMountCB::TimeOffset() const
  4377 TTimeIntervalSeconds CFatMountCB::TimeOffset() const
  4367 	{
  4378 	{
  4368     if((Drive().Att() & KDriveAttRemovable) && FatFileSystem().GetUseLocalTime() )
  4379     if((Drive().Att() & KDriveAttRemovable) && FatFileSystem().GetUseLocalTime() )
  4369 	    {
       
  4370         return User::UTCOffset();
  4380         return User::UTCOffset();
  4371         }
  4381 
  4372 	else
  4382     
  4373         {
  4383     return TTimeIntervalSeconds(0);
  4374         return TTimeIntervalSeconds(0);
       
  4375         }
       
  4376 	}
  4384 	}
  4377 
  4385 
  4378 
  4386 
  4379 
  4387 
  4380 
  4388 
  4429         
  4437         
  4430         case EFat12: 
  4438         case EFat12: 
  4431         return  EOF_12Bit-7; //-- 0xff8
  4439         return  EOF_12Bit-7; //-- 0xff8
  4432         
  4440         
  4433         default: 
  4441         default: 
  4434         ASSERT(aFatType == EInvalid); 
  4442         break;
  4435         return 0;
  4443         }
  4436         }
  4444 
  4437 
  4445     ASSERT(aFatType == EInvalid); 
       
  4446     return 0;
  4438     }
  4447     }
  4439 
  4448 
  4440 //-----------------------------------------------------------------------------------------
  4449 //-----------------------------------------------------------------------------------------
  4441 /**
  4450 /**
  4442     Set FAT type that this object of CFatMountCB will be dealing with.
  4451     Set FAT type that this object of CFatMountCB will be dealing with.