userlibandfileserver/fileserver/sfat32/sl_mnt.cpp
branchRCL_3
changeset 62 4a8fed1c0ef6
parent 36 538db54a451d
child 80 597aaf25e343
equal deleted inserted replaced
52:2d65c2f76d7b 62:4a8fed1c0ef6
  1062         User::Leave(nRes);
  1062         User::Leave(nRes);
  1063 
  1063 
  1064     const TBool newFileExists = (nRes == KErrNone); //-- ETrue if 'aNewName' file exists.
  1064     const TBool newFileExists = (nRes == KErrNone); //-- ETrue if 'aNewName' file exists.
  1065     const TBool bNewNameIsVFAT = !IsLegalDosName(ptrNewName, EFalse, EFalse, EFalse, EFalse, ETrue);
  1065     const TBool bNewNameIsVFAT = !IsLegalDosName(ptrNewName, EFalse, EFalse, EFalse, EFalse, ETrue);
  1066 
  1066 
       
  1067     if(!newFileExists)
       
  1068     {//-- invalidate directory iterators if aNewName doesn't exist
       
  1069         newName_VFatEntryPos.SetEndOfDir();
       
  1070         aNewName_DosEntryPos.SetEndOfDir();
       
  1071     }
       
  1072 
       
  1073 
  1067     if(renameMode && newFileExists)
  1074     if(renameMode && newFileExists)
  1068     	{
  1075     	{
  1069         if(!namesAreIdentical)
  1076         if(!namesAreIdentical)
  1070         {
  1077         {
  1071         if ((newName_DosEntry.Attributes()&KEntryAttDir) != (oldName_DosEntry.Attributes()&KEntryAttDir))
  1078         if ((newName_DosEntry.Attributes()&KEntryAttDir) != (oldName_DosEntry.Attributes()&KEntryAttDir))
  1141         	{//-- need to generate a short name for VFAT entryset DOS entry
  1148         	{//-- need to generate a short name for VFAT entryset DOS entry
  1142             TShortName shortName;
  1149             TShortName shortName;
  1143 
  1150 
  1144 		    if (iFileCreationHelper.GetValidatedShortName(shortName) == KErrNotFound)
  1151 		    if (iFileCreationHelper.GetValidatedShortName(shortName) == KErrNotFound)
  1145 		    	{
  1152 		    	{
  1146 		        GenerateShortNameL(aNewName_DosEntryPos.Cluster(), ptrNewName, shortName, ETrue);
  1153 		        GenerateShortNameL(aNewName_ParentDirPos.Cluster(), ptrNewName, shortName); 
  1147 		    	}
  1154 		    	}
  1148 
  1155 
  1149             newDosEntry.SetName(shortName);
  1156             newDosEntry.SetName(shortName);
  1150         	}
  1157         	}
  1151         else
  1158         else
  1969     TEntryPos       StartEntryPos1(aStartEntryPos);
  1976     TEntryPos       StartEntryPos1(aStartEntryPos);
  1970     TEntryPos       DosEntryPos1(aDosEntryPos);
  1977     TEntryPos       DosEntryPos1(aDosEntryPos);
  1971     TFatDirEntry    StartEntry1(aStartEntry);
  1978     TFatDirEntry    StartEntry1(aStartEntry);
  1972     TFatDirEntry    DosEntry1(aDosEntry);
  1979     TFatDirEntry    DosEntry1(aDosEntry);
  1973 
  1980 
  1974     TInt64          nCachedLinPos;
       
  1975 
       
  1976     const TUint32 clSize = 1 << ClusterSizeLog2(); //-- media cluster size
  1981     const TUint32 clSize = 1 << ClusterSizeLog2(); //-- media cluster size
  1977     const TUint32 cacheSz = pDirCache->CacheSizeInBytes(); //-- cache size in bytes
  1982     const TUint32 cacheSz = pDirCache->CacheSizeInBytes(); //-- cache size in bytes
  1978     const TUint32 maxDirEntries = cacheSz >> KSizeOfFatDirEntryLog2;  //-- maximal number of dir entries that can be in the cache
  1983     const TUint32 maxDirEntries = cacheSz >> KSizeOfFatDirEntryLog2;  //-- maximal number of dir entries that can be in the cache
  1979 
  1984 
  1980     const TUint	  pageSzLog2 = pDirCache->PageSizeInBytesLog2();
  1985     const TUint	  pageSzLog2 = pDirCache->PageSizeInBytesLog2();
  2019         const TUint32 pageStartPos = CalculatePageOffsetInCluster(DosEntryPos1.iPos, pageSzLog2);
  2024         const TUint32 pageStartPos = CalculatePageOffsetInCluster(DosEntryPos1.iPos, pageSzLog2);
  2020     	DosEntryPos1.iPos = pageStartPos;
  2025     	DosEntryPos1.iPos = pageStartPos;
  2021         TBool	PassedPageBoundary = EFalse;
  2026         TBool	PassedPageBoundary = EFalse;
  2022 
  2027 
  2023         const TInt64  entryLinPos = MakeLinAddrL(DosEntryPos1); //-- linear media position of the cluster for this directory
  2028         const TInt64  entryLinPos = MakeLinAddrL(DosEntryPos1); //-- linear media position of the cluster for this directory
  2024         const TUint32 cachePageSz = pDirCache->PosCached(entryLinPos, nCachedLinPos); //-- indicates if entryLinPos is cached
  2029         const TUint32 cachePageSz = pDirCache->PosCached(entryLinPos); //-- indicates if entryLinPos is cached
  2025         if(cachePageSz)
  2030         if(cachePageSz)
  2026             {//-- current page is in the directory cache
  2031             {//-- current page is in the directory cache
  2027              //__PRINT2(_L("#-!! CFatMountCB::DoRummageDirCacheL() Searching cl:%d, lin Pos:%X"),DosEntryPos1.iCluster,(TUint32)entryLinPos);
  2032              //__PRINT2(_L("#-!! CFatMountCB::DoRummageDirCacheL() Searching cl:%d, lin Pos:%X"),DosEntryPos1.iCluster,(TUint32)entryLinPos);
  2028 
  2033 
  2029             //-- search to the end of the cached page.
  2034             //-- search to the end of the cached page.
  3959     TFatDirEntry startEntry;
  3964     TFatDirEntry startEntry;
  3960     TFileName dummyLongName;
  3965     TFileName dummyLongName;
  3961 
  3966 
  3962     FOREVER
  3967     FOREVER
  3963         {
  3968         {
  3964 #ifdef _DEBUG
       
  3965         const TInt e= GetDirEntry(aDosEntryPos, aDosEntry, startEntry, dummyLongName);
       
  3966         __PRINT1(_L("CFatMountCB::FindVolumeLabelFileL: GetDir %d"), e);
       
  3967         User::LeaveIfError(e);
       
  3968 #else
       
  3969         User::LeaveIfError(GetDirEntry(aDosEntryPos, aDosEntry, startEntry, dummyLongName));
  3969         User::LeaveIfError(GetDirEntry(aDosEntryPos, aDosEntry, startEntry, dummyLongName));
  3970 #endif
  3970 
  3971         if(aDosEntry.IsEndOfDirectory())
  3971         if(aDosEntry.IsEndOfDirectory())
  3972             {
  3972             {
  3973             __PRINT(_L("-CFatMountCB::FindVolumeLabelFileL: end of dir"));
  3973             __PRINT(_L("-CFatMountCB::FindVolumeLabelFileL: end of dir"));
  3974             User::Leave(KErrNotFound);
  3974             User::Leave(KErrNotFound);
  3975             }
  3975             }
       
  3976 
  3976         if(IsRootDir(aDosEntryPos) && (aDosEntryPos.iPos+StartOfRootDirInBytes()==(RootDirEnd()-KSizeOfFatDirEntry)))
  3977         if(IsRootDir(aDosEntryPos) && (aDosEntryPos.iPos+StartOfRootDirInBytes()==(RootDirEnd()-KSizeOfFatDirEntry)))
  3977             {
  3978             {
  3978             if(aDosEntry.IsErased())
  3979             if(aDosEntry.IsErased())
  3979                 {
  3980                 {
  3980                 __PRINT(_L("-CFatMountCB::FindVolumeLabelFileL: erased end of root"));
  3981                 __PRINT(_L("-CFatMountCB::FindVolumeLabelFileL: erased end of root"));
  3981                 User::Leave(KErrNotFound); //Allows maximum number of entries in root directory
  3982                 User::Leave(KErrNotFound); //Allows maximum number of entries in root directory
  3982                 }
  3983                 }
  3983             }
  3984             }
       
  3985 
  3984         if(!aDosEntry.IsCurrentDirectory() && !aDosEntry.IsParentDirectory() && !aDosEntry.IsErased() && !aDosEntry.IsGarbage())
  3986         if(!aDosEntry.IsCurrentDirectory() && !aDosEntry.IsParentDirectory() && !aDosEntry.IsErased() && !aDosEntry.IsGarbage())
  3985             {
  3987             {
  3986             if(aDosEntry.Attributes() & KEntryAttVolume)
  3988             if(aDosEntry.Attributes() & KEntryAttVolume)
  3987                 {
  3989                 {
  3988                 aLabel = aDosEntry.Name();
  3990                 aLabel = aDosEntry.Name();
  3989 #ifdef _DEBUG
       
  3990                 dummyLongName.Copy(aLabel);
  3991                 dummyLongName.Copy(aLabel);
  3991                 __PRINT1(_L("-CFatMountCB::FindVolumeLabelFileL: found [%S]"), &dummyLongName);
  3992                 __PRINT1(_L("-CFatMountCB::FindVolumeLabelFileL: found [%S]"), &dummyLongName);
  3992 #endif
       
  3993                 break;
  3993                 break;
  3994                 }
  3994                 }
  3995             }
  3995             }
       
  3996         
  3996         MoveToNextEntryL(aDosEntryPos);
  3997         MoveToNextEntryL(aDosEntryPos);
       
  3998         
  3997         if(IsRootDir(aDosEntryPos) && (aDosEntryPos.iPos+StartOfRootDirInBytes()>=RootDirEnd()))
  3999         if(IsRootDir(aDosEntryPos) && (aDosEntryPos.iPos+StartOfRootDirInBytes()>=RootDirEnd()))
  3998             {
  4000             {
  3999             __PRINT(_L("-CFatMountCB::FindVolumeLabelFileL: passed end of root"));
  4001             __PRINT(_L("-CFatMountCB::FindVolumeLabelFileL: Not found"));
  4000             User::Leave(KErrNotFound); //Allows maximum number of entries in root directory
  4002             User::Leave(KErrNotFound); //Allows maximum number of entries in root directory
  4001             }
  4003             }
       
  4004         
  4002         if(aDosEntryPos.iCluster && (aDosEntryPos.iPos <= previousPosition))
  4005         if(aDosEntryPos.iCluster && (aDosEntryPos.iPos <= previousPosition))
  4003             {
  4006             {
  4004             DoCheckFatForLoopsL(aDosEntryPos.iCluster, previousCluster, changePreviousCluster, count);
  4007             DoCheckFatForLoopsL(aDosEntryPos.iCluster, previousCluster, changePreviousCluster, count);
  4005             }
  4008             }
       
  4009 
  4006         previousPosition=aDosEntryPos.iPos;
  4010         previousPosition=aDosEntryPos.iPos;
  4007         }
  4011         }
  4008     }
  4012     }
  4009 
  4013 
  4010 //-----------------------------------------------------------------------------------------
  4014 //-----------------------------------------------------------------------------------------