userlibandfileserver/fileserver/sfat32/inc/sl_std.inl
branchRCL_3
changeset 22 2f92ad2dc5db
parent 19 4a8fed1c0ef6
child 42 a179b74831c9
equal deleted inserted replaced
21:e7d2d738d3c2 22:2f92ad2dc5db
    59 
    59 
    60     return (aClusterNo >= KFatFirstSearchCluster) && (aClusterNo < UsableClusters()+KFatFirstSearchCluster); 
    60     return (aClusterNo >= KFatFirstSearchCluster) && (aClusterNo < UsableClusters()+KFatFirstSearchCluster); 
    61     }
    61     }
    62 
    62 
    63 
    63 
    64 inline TInt CFatMountCB::RootDirectorySector() const
    64 inline TUint32 CFatMountCB::RootDirectorySector() const
    65     {return iVolParam.RootDirectorySector();}
    65     {
    66 
    66     return iVolParam.RootDirectorySector();
    67 inline TUint CFatMountCB::RootDirEnd() const
    67     }
    68     {return iVolParam.RootDirEnd();}
    68 
       
    69 inline TUint32 CFatMountCB::RootDirEnd() const
       
    70     {
       
    71     return iVolParam.RootDirEnd();
       
    72     }
    69 
    73 
    70 inline TUint32 CFatMountCB::RootClusterNum() const
    74 inline TUint32 CFatMountCB::RootClusterNum() const
    71     {return iVolParam.RootClusterNum(); }        
    75     {
    72 
    76     return iVolParam.RootClusterNum();
    73 
    77     }        
    74 inline TInt CFatMountCB::StartCluster(const TFatDirEntry & anEntry) const
    78 
       
    79 
       
    80 inline TUint32 CFatMountCB::StartCluster(const TFatDirEntry & anEntry) const
    75 	{
    81 	{
    76 	if(Is32BitFat())	
    82 	if(Is32BitFat())	
    77 		return anEntry.StartCluster();
    83 		return anEntry.StartCluster();
    78 	else
    84 	else
    79 		return 0xFFFF&anEntry.StartCluster();
    85 		return anEntry.StartCluster() & 0xFFFF;
    80 	}
    86 	}
    81 
    87 
    82 /**
    88 /**
    83 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 
    84 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.
    85 
    91 
    86 @param aEntry position on volume being queried
    92     @param entryPos     directory entry position
    87 @return Whether Root dir position or not
    93     @return ETrue       if entryPos belongs to the FAT12/16 root directory
    88 */
    94 */
    89 TBool CFatMountCB::IsRootDir(const TEntryPos &aEntry) const
    95 TBool CFatMountCB::IsRootDir(const TEntryPos &entryPos) const
    90 	{
    96 	{
    91 	if(Is32BitFat())
    97 	//-- for FAT12/16 cluster 0 means "root directory"
    92 		return EFalse;
    98     return !(Is32BitFat() || entryPos.iCluster);
    93 	else
       
    94 		return((aEntry.iCluster==0) ? (TBool)ETrue : (TBool)EFalse);	
       
    95 	}
    99 	}
    96 /**
   100 /**
    97 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
    98 @return The root cluster indicator
   102 @return The root cluster indicator
    99 */
   103 */
   100 TInt CFatMountCB::RootIndicator() const
   104 TUint32 CFatMountCB::RootIndicator() const
   101 	{
   105 	{
   102 	if(Is32BitFat())
   106 	if(Is32BitFat())
   103         return iVolParam.RootClusterNum();
   107         return iVolParam.RootClusterNum();
   104 	else
   108 	else
   105 		return 0;
   109 		return 0;
   106 	}
   110 	}
   107 
   111 
   108 
   112 
   109 /** @return Log2 of cluster size on volume */
   113 /** @return Log2 of cluster size on volume */
   110 TInt CFatMountCB::ClusterSizeLog2() const
   114 TUint32 CFatMountCB::ClusterSizeLog2() const
   111     {return(iVolParam.ClusterSizeLog2());}
   115     {
       
   116     return(iVolParam.ClusterSizeLog2());
       
   117     }
   112 
   118 
   113 /** @return Log2 of media sector size  */
   119 /** @return Log2 of media sector size  */
   114 TInt CFatMountCB::SectorSizeLog2() const
   120 TUint32 CFatMountCB::SectorSizeLog2() const
   115     {return(iVolParam.SectorSizeLog2());}
   121     {
       
   122     return(iVolParam.SectorSizeLog2());
       
   123     }
   116 
   124 
   117 /** @return sector per cluster */
   125 /** @return sector per cluster */
   118 TInt CFatMountCB::SectorsPerCluster() const
   126 TUint32 CFatMountCB::SectorsPerCluster() const
   119     {return(1<<(iVolParam.ClusterSizeLog2()-iVolParam.SectorSizeLog2()));}
   127     {
       
   128     return(1<<(iVolParam.ClusterSizeLog2()-iVolParam.SectorSizeLog2()));
       
   129     }
   120 
   130 
   121 /** @return the base position of a cluster */
   131 /** @return the base position of a cluster */
   122 TInt CFatMountCB::ClusterBasePosition() const
   132 TUint32 CFatMountCB::ClusterBasePosition() const
   123 	{return(iFirstFreeByte);}
   133 	{
       
   134     return(iFirstFreeByte);
       
   135     }
   124 
   136 
   125 /** @return the offset into a cluster of a byte address */
   137 /** @return the offset into a cluster of a byte address */
   126 TInt CFatMountCB::ClusterRelativePos(TInt aPos) const
   138 TUint32 CFatMountCB::ClusterRelativePos(TUint32 aPos) const
   127 	{return(aPos&((1<<ClusterSizeLog2())-1));}
   139 	{
       
   140     return(aPos & ((1<<ClusterSizeLog2())-1));
       
   141     }
   128 
   142 
   129 /**
   143 /**
   130 Calculates the maximum number of clusters
   144 Calculates the maximum number of clusters
   131 @return  maximum number of clusters
   145 @return  maximum number of clusters
   132 */
   146 */
   133 TUint32 CFatMountCB::MaxClusterNumber() const
   147 TUint32 CFatMountCB::MaxClusterNumber() const
   134     {return(TotalSectors()>>(ClusterSizeLog2()-SectorSizeLog2()));}
   148     {return(TotalSectors()>>(ClusterSizeLog2()-SectorSizeLog2()));}
   135 
   149 
   136 /** @return the the total sectors on volume */
   150 /** @return the the total sectors on volume */
   137 TInt CFatMountCB::TotalSectors() const
   151 TUint32 CFatMountCB::TotalSectors() const
   138     {return iVolParam.TotalSectors();}
   152     {
       
   153     return iVolParam.TotalSectors();
       
   154     }
   139 
   155 
   140 /** @return total size of a Fat in bytes */
   156 /** @return total size of a Fat in bytes */
   141 TInt CFatMountCB::FatSizeInBytes() const
   157 TUint32 CFatMountCB::FatSizeInBytes() const
   142     {return iVolParam.FatSizeInBytes();}
   158     {
       
   159     return iVolParam.FatSizeInBytes();
       
   160     }
   143 
   161 
   144 /** @return first sector of the Fat */
   162 /** @return first sector of the Fat */
   145 TUint32 CFatMountCB::FirstFatSector() const
   163 TUint32 CFatMountCB::FirstFatSector() const
   146     {return iVolParam.FirstFatSector();}
   164     {
       
   165     return iVolParam.FirstFatSector();
       
   166     }
   147 
   167 
   148 /** @return the byte offset of the Fat */
   168 /** @return the byte offset of the Fat */
   149 TInt CFatMountCB::StartOfFatInBytes() const
   169 TUint32 CFatMountCB::StartOfFatInBytes() const
   150 	{return(FirstFatSector()<<SectorSizeLog2());}
   170 	{
       
   171     return(FirstFatSector()<<SectorSizeLog2());
       
   172     }
   151 
   173 
   152 /** @return Number of Fats used by the volume */
   174 /** @return Number of Fats used by the volume */
   153 TInt CFatMountCB::NumberOfFats() const
   175 TUint32 CFatMountCB::NumberOfFats() const
   154     {return iVolParam.NumberOfFats();}
   176     {
       
   177     return iVolParam.NumberOfFats();
       
   178     }
   155 
   179 
   156 
   180 
   157 /** @return refrence to the fat table owned by the mount */
   181 /** @return refrence to the fat table owned by the mount */
   158 CFatTable& CFatMountCB::FAT() const
   182 CFatTable& CFatMountCB::FAT() const
   159 	{return(*iFatTable);}
   183 	{
       
   184     return(*iFatTable);
       
   185     }
       
   186 
   160 /**
   187 /**
   161     @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
   162 */
   189 */
   163 CFatFileSystem& CFatMountCB::FatFileSystem() const
   190 CFatFileSystem& CFatMountCB::FatFileSystem() const
   164 	{
   191 	{
   171 	{return(*iRawDisk);}
   198 	{return(*iRawDisk);}
   172 
   199 
   173 /**
   200 /**
   174 @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
   175 */
   202 */
   176 TBool CFatMountCB::IsBadCluster(TInt aCluster) const
   203 TBool CFatMountCB::IsBadCluster(TUint32 aCluster) const
   177 	{return Is32BitFat() ? aCluster==0xFFFFFF7 : Is16BitFat() ? aCluster==0xFFF7 : aCluster==0xFF7;}
   204 	{
       
   205     return Is32BitFat() ? aCluster==0xFFFFFF7 : Is16BitFat() ? aCluster==0xFFF7 : aCluster==0xFF7;
       
   206     }
   178 
   207 
   179 /**
   208 /**
   180 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
   181     @return ETrue if this is Rugged FAT
   210     @return ETrue if this is Rugged FAT
   182 */
   211 */
   193 	{
   222 	{
   194     Drive().SetRugged(aVal);
   223     Drive().SetRugged(aVal);
   195     }
   224     }
   196 
   225 
   197 /**
   226 /**
   198     @return Log2(Meida atomic write granularity).
   227     @return Log2(Media atomic write granularity).
   199     This is mostly to be used in Rugged FAT mode, see IsRuggedFSys(). For Rugged FAT the media shall support atomic writes.
   228     This is mostly to be used in Rugged FAT mode, see IsRuggedFSys(). For Rugged FAT the media shall support atomic writes.
   200     By default this is the sector (512 bytes)
   229     By default this is the sector (512 bytes)
   201 
   230 
   202 */
   231 */
   203 TUint32 CFatMountCB::AtomicWriteGranularityLog2() const
   232 TUint32 CFatMountCB::AtomicWriteGranularityLog2() const
   206     }
   235     }
   207 
   236 
   208 
   237 
   209 /** @return the usable clusters count for a volume */
   238 /** @return the usable clusters count for a volume */
   210 TUint32 CFatMountCB::UsableClusters() const
   239 TUint32 CFatMountCB::UsableClusters() const
   211 	{return(iUsableClusters);}
   240     {
   212 
   241     return(iUsableClusters);
   213 
   242     }
   214 TUint CFatMountCB::StartOfRootDirInBytes() const
   243 
   215     {return iVolParam.RootDirectorySector()<<SectorSizeLog2();}
   244 
       
   245 TUint32 CFatMountCB::StartOfRootDirInBytes() const
       
   246     {
       
   247     return iVolParam.RootDirectorySector()<<SectorSizeLog2();
       
   248     }
   216 
   249 
   217 
   250 
   218 /** @return FAT type for this mount */
   251 /** @return FAT type for this mount */
   219 TFatType CFatMountCB::FatType() const
   252 TFatType CFatMountCB::FatType() const
   220 {
   253 {
   232 {   
   265 {   
   233     return FatType() == EFat32;
   266     return FatType() == EFat32;
   234 }
   267 }
   235 
   268 
   236 CAsyncNotifier* CFatMountCB::Notifier() const
   269 CAsyncNotifier* CFatMountCB::Notifier() const
   237 	{return iNotifier;}	
   270 	{
       
   271     return iNotifier;
       
   272     }	
   238 
   273 
   239 
   274 
   240 
   275 
   241 /**
   276 /**
   242     Set or reset Read Only mode for the mount.
   277     Set or reset Read Only mode for the mount.
   348 /**
   383 /**
   349     Checks for "EOC" for all Fat types
   384     Checks for "EOC" for all Fat types
   350     @param  aCluster FAT table entry (cluster number) to check
   385     @param  aCluster FAT table entry (cluster number) to check
   351     @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
   352 */
   387 */
   353 TBool CFatMountCB::IsEndOfClusterCh(TInt aCluster) const
   388 TBool CFatMountCB::IsEndOfClusterCh(TUint32 aCluster) const
   354 	{
   389 	{
   355     ASSERT(iFatEocCode);
   390     ASSERT(iFatEocCode);
   356 
   391     ASSERT((TUint32)aCluster <= iFatEocCode+7); //-- aCluster value is always masked accordingly.
   357     if((TUint32)aCluster >= iFatEocCode)
   392 
   358         return ETrue;
   393     return (aCluster >= iFatEocCode);
   359 
       
   360     ASSERT((TUint32)aCluster <= iFatEocCode+7);
       
   361 
       
   362 	return EFalse;
       
   363     }
   394     }
   364 
   395 
   365 /**
   396 /**
   366     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.
   367     @param aCluster cluster to set to end of chain marker
   398     @param aCluster cluster to set to end of chain marker
   368 */
   399 */
   369 void CFatMountCB::SetEndOfClusterCh(TInt &aCluster) const
   400 void CFatMountCB::SetEndOfClusterCh(TUint32 &aCluster) const
   370 	{
   401 	{
   371     ASSERT(iFatEocCode);
   402     ASSERT(iFatEocCode);
   372     aCluster = iFatEocCode+7;
   403     aCluster = iFatEocCode+7;
   373 	}
   404 	}
   374 
   405 
   482 @return cluster size
   513 @return cluster size
   483 */
   514 */
   484 TInt CFatFileCB::ClusterSizeLog2()
   515 TInt CFatFileCB::ClusterSizeLog2()
   485 	{return(FatMount().ClusterSizeLog2());}
   516 	{return(FatMount().ClusterSizeLog2());}
   486 
   517 
   487 /*
   518 
   488  Note: this replaces SeekIndex() which was only used in sl_mnt
   519 //---------------------------------------------------------------------------------------------------------------------------------
   489  to verify whether the seek index had been created/initialised
   520 TBool CFatFileCB::FileSizeModified() const 
   490 */
   521     {
   491 inline TBool CFatFileCB::IsSeekIndex() const
   522     return iFileSizeModified;
   492 {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 
   493 
   584 
   494 
   585 
   495 //---------------------------------------------------------------------------------------------------------------------------------
   586 //---------------------------------------------------------------------------------------------------------------------------------
   496 // class CFatDirCB
   587 // class CFatDirCB
   497 
   588