userlibandfileserver/fileserver/sfat/filesystem_fat.h
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 // Public header file for "FAT" file system. Contains this file system name and optional file system - specific declarations.
       
    16 //
       
    17 //
       
    18 //
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @publishedAll
       
    24  @released
       
    25 */
       
    26 
       
    27 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    29 //!!
       
    30 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
       
    31 //!!
       
    32 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    33 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    34 
       
    35 
       
    36 #if !defined(__FILESYSTEM_FAT_H__)
       
    37 #define __FILESYSTEM_FAT_H__
       
    38 
       
    39 
       
    40 #if !defined(__F32FILE_H__)
       
    41 #include <f32file.h>
       
    42 #endif
       
    43 
       
    44 
       
    45 
       
    46 /**
       
    47     FAT filesystem name, which shall be provided to RFs::MountFileSystem() and is returned by RFs::FileSystemName() if 
       
    48     this file system is mounted on the drive. The literal is case-insensitive.
       
    49     @see RFs::MountFileSystem()
       
    50     @see RFs::FileSystemName()
       
    51 */
       
    52 _LIT(KFileSystemName_FAT, "FAT");
       
    53 
       
    54 /**
       
    55     FAT file system subtypes, literal values. These values are returned by RFs::FileSystemSubType().
       
    56     The literals are case-insensitive.
       
    57     File sytem "FAT" mounted on the drive can be one of the FAT12/FAT16/FAT32
       
    58 
       
    59     @see RFs::::FileSystemSubType()
       
    60 */
       
    61 _LIT(KFSSubType_FAT12, "FAT12"); ///< corresponds to FAT12
       
    62 _LIT(KFSSubType_FAT16, "FAT16"); ///< corresponds to FAT16   
       
    63 _LIT(KFSSubType_FAT32, "FAT32"); ///< corresponds to FAT32
       
    64 
       
    65 //------------------------------------------------------------------------------
       
    66 
       
    67 namespace FileSystem_FAT
       
    68 {
       
    69 
       
    70     /** Numeric representation of FAT file system sub types */
       
    71     enum TFatSubType
       
    72         {
       
    73         EInvalid = 0,       ///< invalid terminal value
       
    74         ENotSpecified = 0,  ///< not specified
       
    75 
       
    76         EFat12  = 12,   ///< corresponds to FAT12
       
    77         EFat16  = 16,   ///< corresponds to FAT16
       
    78         EFat32  = 32    ///< corresponds to FAT32
       
    79         };
       
    80 
       
    81 
       
    82 const TUint64 KMaxSupportedFatFileSize = 0xFFFFFFFF; ///< theoretical maximum file size supported by all FAT filesystems (4GB-1)
       
    83 
       
    84 //------------------------------------------------------------------------------
       
    85 
       
    86 /** 
       
    87     This class describes specific parameters for formatting volume with FAT file system.
       
    88     The parameters are: FAT sub type (FAT12/16/32), Number of Sectors per cluster, Number of FAT tables, Number of reserved sectors.
       
    89     All parameters are optional and if not set, it is up to the file system implementation to decide values.
       
    90 
       
    91     This class package (TVolFormatParam_FATBuf) shall be passed to the RFormat::Open() as "Special format information"
       
    92 
       
    93     Please note that the parameters may have invalid combinations and it is not always possible to format volume with the specified
       
    94     FAT sub type, like FAT12. In this case RFormat::Open() will return corresponding error code (the concrete code depends on file system implementation).
       
    95 
       
    96     RFormat::Open() does not modify any data in this structure.
       
    97 
       
    98     @see TVolFormatParam_FATBuf
       
    99     @see RFormat::Open()
       
   100 */ 
       
   101 class TVolFormatParam_FAT : public TVolFormatParam
       
   102 {
       
   103  public:    
       
   104     inline TVolFormatParam_FAT();
       
   105     inline void Init();
       
   106 
       
   107     inline void SetFatSubType(TFatSubType aSubType);
       
   108     inline void SetFatSubType(const TDesC& aSubType);
       
   109     inline TFatSubType FatSubType() const;
       
   110     //--
       
   111     inline void SetSectPerCluster(TUint32 aSpc);
       
   112     inline TUint32 SectPerCluster() const;
       
   113     //--
       
   114     inline void SetNumFATs(TUint32 aNumFATs);
       
   115     inline TUint32 NumFATs() const;
       
   116 
       
   117     //--
       
   118     inline void SetReservedSectors(TUint32 aReservedSectors);
       
   119     inline TUint32 ReservedSectors() const;
       
   120 
       
   121 
       
   122  private:
       
   123     void SetFileSystemName(const TDesC& aFsName);
       
   124     
       
   125     enum ///< offsets of the data units in parent class container
       
   126         {
       
   127         KOffsetSubType =0,  //-- 0
       
   128         KOffsetReservedSec, //-- 1
       
   129         KOffsetSpc,         //-- 2
       
   130         KOffsetNumFATs,     //-- 3
       
   131         
       
   132         };
       
   133 
       
   134 }; //TVolFormatParam_FAT
       
   135 
       
   136 
       
   137 /**
       
   138     TVolFormatParam_FAT package buffer to be passed to RFormat::Open().
       
   139     @see TVolFormatParam_FAT
       
   140     @see RFormat::Open()
       
   141 */ 
       
   142 typedef TPckgBuf<TVolFormatParam_FAT> TVolFormatParam_FATBuf;
       
   143 
       
   144 
       
   145 
       
   146 //------------------------------------------------------------------------------
       
   147 //-- inline functions 
       
   148 //------------------------------------------------------------------------------
       
   149 
       
   150 TVolFormatParam_FAT::TVolFormatParam_FAT() : TVolFormatParam() 
       
   151     {
       
   152      __ASSERT_COMPILE(sizeof(TVolFormatParam_FAT) == sizeof(TVolFormatParam));
       
   153      Init();
       
   154     }
       
   155 
       
   156 //------------------------------------------------------------------------------
       
   157 /** initialises the data structure with default values for all parameters and automatically sets file system name as "FAT" */
       
   158 void TVolFormatParam_FAT::Init() 
       
   159     {
       
   160     TVolFormatParam::Init(); 
       
   161     TVolFormatParam::SetFileSystemName(KFileSystemName_FAT);
       
   162     }
       
   163 
       
   164 //------------------------------------------------------------------------------
       
   165 /**
       
   166     Set desired FAT subtype. 
       
   167     @param  aSubType specifies FAT12/16/32 subtype. Value 0 means "the file system will decide itself what to use"
       
   168 */
       
   169 void TVolFormatParam_FAT::SetFatSubType(TFatSubType aSubType)
       
   170     {
       
   171     ASSERT(aSubType == ENotSpecified || aSubType == EFat12 || aSubType == EFat16 || aSubType == EFat32);
       
   172     SetVal(KOffsetSubType, aSubType);
       
   173     }
       
   174 
       
   175 //------------------------------------------------------------------------------
       
   176 /**
       
   177     Set desired FAT subtype using string literals, @see KFSSubType_FAT12, @see KFSSubType_FAT16, @see KFSSubType_FAT32               
       
   178     @param  aSubType    string descriptor, like "FAT16"
       
   179 */
       
   180 void TVolFormatParam_FAT::SetFatSubType(const TDesC& aSubType)
       
   181     {
       
   182     TFatSubType fatType = ENotSpecified;
       
   183 
       
   184     if(aSubType.CompareF(KFSSubType_FAT12) == 0)
       
   185         fatType = EFat12;
       
   186     else if(aSubType.CompareF(KFSSubType_FAT16) == 0)
       
   187         fatType = EFat16;
       
   188     else if(aSubType.CompareF(KFSSubType_FAT32) == 0)
       
   189         fatType = EFat32;
       
   190     else
       
   191         { ASSERT(0);}
       
   192 
       
   193 
       
   194         SetFatSubType(fatType);
       
   195     }
       
   196 
       
   197 //------------------------------------------------------------------------------
       
   198 /** @return FAT sub type value, which is set by SetFatSubType()*/
       
   199 TFatSubType TVolFormatParam_FAT::FatSubType() const 
       
   200     {
       
   201     return (TFatSubType)GetVal(KOffsetSubType);
       
   202     }
       
   203 
       
   204 //------------------------------------------------------------------------------
       
   205 /**
       
   206     Set Number of "Sectors per cluster". For valid values see FAT specs.
       
   207     @param  aSpc    Number of "Sectors per cluster". Value 0 means "the file system will decide itself what to use"       
       
   208 */
       
   209 void TVolFormatParam_FAT::SetSectPerCluster(TUint32 aSpc)
       
   210     {
       
   211     SetVal(KOffsetSpc, aSpc);
       
   212     }
       
   213 
       
   214 //------------------------------------------------------------------------------
       
   215 /** @return value previously set by SetSectPerCluster() */
       
   216 TUint32 TVolFormatParam_FAT::SectPerCluster() const 
       
   217     {
       
   218     return GetVal(KOffsetSpc);
       
   219     }
       
   220 
       
   221 //------------------------------------------------------------------------------
       
   222 /**
       
   223     Set Number of FAT tables on the volume. The maximum is supported by the FAT FS implementation is 2
       
   224     @param  aNumFATs    Number of FAT tables. Value 0 means "the file system will decide itself what to use"       
       
   225 */
       
   226 void TVolFormatParam_FAT::SetNumFATs(TUint32 aNumFATs) 
       
   227     {
       
   228     SetVal(KOffsetNumFATs, aNumFATs);
       
   229     }
       
   230 
       
   231 //------------------------------------------------------------------------------
       
   232 /** @return value previously set by SetNumFATs() */
       
   233 TUint32 TVolFormatParam_FAT::NumFATs() const 
       
   234     {
       
   235     return GetVal(KOffsetNumFATs);
       
   236     } 
       
   237 
       
   238 //------------------------------------------------------------------------------
       
   239 /**
       
   240     Set number of reserved sectors on FAT volume. The file system will validate this parameter before formatting.
       
   241     @param  aReservedSectors  number of reserved sectors. Value 0 means "the file system will decide itself what to use"       
       
   242 */
       
   243 void TVolFormatParam_FAT::SetReservedSectors(TUint32 aReservedSectors)
       
   244     {
       
   245     SetVal(KOffsetReservedSec, aReservedSectors);
       
   246     }
       
   247 
       
   248 //------------------------------------------------------------------------------
       
   249 /** @return value previously set by SetReservedSectors() */
       
   250 TUint32 TVolFormatParam_FAT::ReservedSectors() const 
       
   251     {
       
   252     return GetVal(KOffsetReservedSec);
       
   253     } 
       
   254 
       
   255 
       
   256 
       
   257 
       
   258 //------------------------------------------------------------------------------
       
   259 
       
   260 
       
   261 
       
   262 }//namespace FileSystem_FAT
       
   263 
       
   264 
       
   265 
       
   266 
       
   267 
       
   268 
       
   269 #endif //__FILESYSTEM_FAT_H__
       
   270 
       
   271 
       
   272 
       
   273 
       
   274 
       
   275 
       
   276 
       
   277 
       
   278 
       
   279 
       
   280 
       
   281 
       
   282 
       
   283 
       
   284