Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // Public header file for "FAT" file system. Contains this file system name and optional file system - specific declarations.
27 #if !defined(__FILESYSTEM_FAT_H__)
28 #define __FILESYSTEM_FAT_H__
31 #if !defined(__F32FILE_H__)
38 FAT filesystem name, which shall be provided to RFs::MountFileSystem() and is returned by RFs::FileSystemName() if
39 this file system is mounted on the drive. The literal is case-insensitive.
40 @see RFs::MountFileSystem()
41 @see RFs::FileSystemName()
43 _LIT(KFileSystemName_FAT, "FAT");
46 FAT file system subtypes, literal values. These values are returned by RFs::FileSystemSubType().
47 The literals are case-insensitive.
48 File sytem "FAT" mounted on the drive can be one of the FAT12/FAT16/FAT32
50 @see RFs::::FileSystemSubType()
52 _LIT(KFSSubType_FAT12, "FAT12"); ///< corresponds to FAT12
53 _LIT(KFSSubType_FAT16, "FAT16"); ///< corresponds to FAT16
54 _LIT(KFSSubType_FAT32, "FAT32"); ///< corresponds to FAT32
56 //------------------------------------------------------------------------------
58 namespace FileSystem_FAT
61 /** Numeric representation of FAT file system sub types */
64 EInvalid = 0, ///< invalid terminal value
65 ENotSpecified = 0, ///< not specified
67 EFat12 = 12, ///< corresponds to FAT12
68 EFat16 = 16, ///< corresponds to FAT16
69 EFat32 = 32 ///< corresponds to FAT32
73 const TUint64 KMaxSupportedFatFileSize = 0xFFFFFFFF; ///< theoretical maximum file size supported by all FAT filesystems (4GB-1)
75 //------------------------------------------------------------------------------
78 This class describes specific parameters for formatting volume with FAT file system.
79 The parameters are: FAT sub type (FAT12/16/32), Number of Sectors per cluster, Number of FAT tables, Number of reserved sectors.
80 All parameters are optional and if not set, it is up to the file system implementation to decide values.
82 This class package (TVolFormatParam_FATBuf) shall be passed to the RFormat::Open() as "Special format information"
84 Please note that the parameters may have invalid combinations and it is not always possible to format volume with the specified
85 FAT sub type, like FAT12. In this case RFormat::Open() will return corresponding error code (the concrete code depends on file system implementation).
87 RFormat::Open() does not modify any data in this structure.
89 @see TVolFormatParam_FATBuf
92 class TVolFormatParam_FAT : public TVolFormatParam
95 inline TVolFormatParam_FAT();
98 inline void SetFatSubType(TFatSubType aSubType);
99 inline void SetFatSubType(const TDesC& aSubType);
100 inline TFatSubType FatSubType() const;
102 inline void SetSectPerCluster(TUint32 aSpc);
103 inline TUint32 SectPerCluster() const;
105 inline void SetNumFATs(TUint32 aNumFATs);
106 inline TUint32 NumFATs() const;
109 inline void SetReservedSectors(TUint32 aReservedSectors);
110 inline TUint32 ReservedSectors() const;
114 void SetFileSystemName(const TDesC& aFsName);
116 enum ///< offsets of the data units in parent class container
118 KOffsetSubType =0, //-- 0
119 KOffsetReservedSec, //-- 1
120 KOffsetSpc, //-- 2 !! do not change this offset.
121 KOffsetNumFATs, //-- 3 !! do not change this offset.
125 }; //TVolFormatParam_FAT
129 TVolFormatParam_FAT package buffer to be passed to RFormat::Open().
130 @see TVolFormatParam_FAT
133 typedef TPckgBuf<TVolFormatParam_FAT> TVolFormatParam_FATBuf;
137 //------------------------------------------------------------------------------
138 //-- inline functions
139 //------------------------------------------------------------------------------
141 TVolFormatParam_FAT::TVolFormatParam_FAT() : TVolFormatParam()
143 __ASSERT_COMPILE(sizeof(TVolFormatParam_FAT) == sizeof(TVolFormatParam));
144 __ASSERT_COMPILE(KOffsetSpc == 2);
145 __ASSERT_COMPILE(KOffsetNumFATs == 3);
150 //------------------------------------------------------------------------------
151 /** initialises the data structure with default values for all parameters and automatically sets file system name as "FAT" */
152 void TVolFormatParam_FAT::Init()
154 TVolFormatParam::Init();
155 TVolFormatParam::SetFileSystemName(KFileSystemName_FAT);
158 //------------------------------------------------------------------------------
160 Set desired FAT subtype.
161 @param aSubType specifies FAT12/16/32 subtype. Value 0 means "the file system will decide itself what to use"
163 void TVolFormatParam_FAT::SetFatSubType(TFatSubType aSubType)
165 ASSERT(aSubType == ENotSpecified || aSubType == EFat12 || aSubType == EFat16 || aSubType == EFat32);
166 SetVal(KOffsetSubType, aSubType);
169 //------------------------------------------------------------------------------
171 Set desired FAT subtype using string literals, @see KFSSubType_FAT12, @see KFSSubType_FAT16, @see KFSSubType_FAT32
172 @param aSubType string descriptor, like "FAT16"
174 void TVolFormatParam_FAT::SetFatSubType(const TDesC& aSubType)
176 TFatSubType fatType = ENotSpecified;
178 if(aSubType.CompareF(KFSSubType_FAT12) == 0)
180 else if(aSubType.CompareF(KFSSubType_FAT16) == 0)
182 else if(aSubType.CompareF(KFSSubType_FAT32) == 0)
188 SetFatSubType(fatType);
191 //------------------------------------------------------------------------------
192 /** @return FAT sub type value, which is set by SetFatSubType()*/
193 TFatSubType TVolFormatParam_FAT::FatSubType() const
195 return (TFatSubType)GetVal(KOffsetSubType);
198 //------------------------------------------------------------------------------
200 Set Number of "Sectors per cluster". For valid values see FAT specs.
201 @param aSpc Number of "Sectors per cluster". Value 0 means "the file system will decide itself what to use"
203 void TVolFormatParam_FAT::SetSectPerCluster(TUint32 aSpc)
205 SetVal(KOffsetSpc, aSpc);
208 //------------------------------------------------------------------------------
209 /** @return value previously set by SetSectPerCluster() */
210 TUint32 TVolFormatParam_FAT::SectPerCluster() const
212 return GetVal(KOffsetSpc);
215 //------------------------------------------------------------------------------
217 Set Number of FAT tables on the volume. The maximum is supported by the FAT FS implementation is 2
218 @param aNumFATs Number of FAT tables. Value 0 means "the file system will decide itself what to use"
220 void TVolFormatParam_FAT::SetNumFATs(TUint32 aNumFATs)
222 SetVal(KOffsetNumFATs, aNumFATs);
225 //------------------------------------------------------------------------------
226 /** @return value previously set by SetNumFATs() */
227 TUint32 TVolFormatParam_FAT::NumFATs() const
229 return GetVal(KOffsetNumFATs);
232 //------------------------------------------------------------------------------
234 Set number of reserved sectors on FAT volume. The file system will validate this parameter before formatting.
235 @param aReservedSectors number of reserved sectors. Value 0 means "the file system will decide itself what to use"
237 void TVolFormatParam_FAT::SetReservedSectors(TUint32 aReservedSectors)
239 SetVal(KOffsetReservedSec, aReservedSectors);
242 //------------------------------------------------------------------------------
243 /** @return value previously set by SetReservedSectors() */
244 TUint32 TVolFormatParam_FAT::ReservedSectors() const
246 return GetVal(KOffsetReservedSec);
252 //------------------------------------------------------------------------------
256 }//namespace FileSystem_FAT
263 #endif //__FILESYSTEM_FAT_H__