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 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
30 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
32 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36 #if !defined(__FILESYSTEM_FAT_H__)
37 #define __FILESYSTEM_FAT_H__
40 #if !defined(__F32FILE_H__)
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()
52 _LIT(KFileSystemName_FAT, "FAT");
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
59 @see RFs::::FileSystemSubType()
61 _LIT(KFSSubType_FAT12, "FAT12"); ///< corresponds to FAT12
62 _LIT(KFSSubType_FAT16, "FAT16"); ///< corresponds to FAT16
63 _LIT(KFSSubType_FAT32, "FAT32"); ///< corresponds to FAT32
65 //------------------------------------------------------------------------------
67 namespace FileSystem_FAT
70 /** Numeric representation of FAT file system sub types */
73 EInvalid = 0, ///< invalid terminal value
74 ENotSpecified = 0, ///< not specified
76 EFat12 = 12, ///< corresponds to FAT12
77 EFat16 = 16, ///< corresponds to FAT16
78 EFat32 = 32 ///< corresponds to FAT32
82 const TUint64 KMaxSupportedFatFileSize = 0xFFFFFFFF; ///< theoretical maximum file size supported by all FAT filesystems (4GB-1)
84 //------------------------------------------------------------------------------
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.
91 This class package (TVolFormatParam_FATBuf) shall be passed to the RFormat::Open() as "Special format information"
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).
96 RFormat::Open() does not modify any data in this structure.
98 @see TVolFormatParam_FATBuf
101 class TVolFormatParam_FAT : public TVolFormatParam
104 inline TVolFormatParam_FAT();
107 inline void SetFatSubType(TFatSubType aSubType);
108 inline void SetFatSubType(const TDesC& aSubType);
109 inline TFatSubType FatSubType() const;
111 inline void SetSectPerCluster(TUint32 aSpc);
112 inline TUint32 SectPerCluster() const;
114 inline void SetNumFATs(TUint32 aNumFATs);
115 inline TUint32 NumFATs() const;
118 inline void SetReservedSectors(TUint32 aReservedSectors);
119 inline TUint32 ReservedSectors() const;
123 void SetFileSystemName(const TDesC& aFsName);
125 enum ///< offsets of the data units in parent class container
127 KOffsetSubType =0, //-- 0
128 KOffsetReservedSec, //-- 1
130 KOffsetNumFATs, //-- 3
134 }; //TVolFormatParam_FAT
138 TVolFormatParam_FAT package buffer to be passed to RFormat::Open().
139 @see TVolFormatParam_FAT
142 typedef TPckgBuf<TVolFormatParam_FAT> TVolFormatParam_FATBuf;
146 //------------------------------------------------------------------------------
147 //-- inline functions
148 //------------------------------------------------------------------------------
150 TVolFormatParam_FAT::TVolFormatParam_FAT() : TVolFormatParam()
152 __ASSERT_COMPILE(sizeof(TVolFormatParam_FAT) == sizeof(TVolFormatParam));
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()
160 TVolFormatParam::Init();
161 TVolFormatParam::SetFileSystemName(KFileSystemName_FAT);
164 //------------------------------------------------------------------------------
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"
169 void TVolFormatParam_FAT::SetFatSubType(TFatSubType aSubType)
171 ASSERT(aSubType == ENotSpecified || aSubType == EFat12 || aSubType == EFat16 || aSubType == EFat32);
172 SetVal(KOffsetSubType, aSubType);
175 //------------------------------------------------------------------------------
177 Set desired FAT subtype using string literals, @see KFSSubType_FAT12, @see KFSSubType_FAT16, @see KFSSubType_FAT32
178 @param aSubType string descriptor, like "FAT16"
180 void TVolFormatParam_FAT::SetFatSubType(const TDesC& aSubType)
182 TFatSubType fatType = ENotSpecified;
184 if(aSubType.CompareF(KFSSubType_FAT12) == 0)
186 else if(aSubType.CompareF(KFSSubType_FAT16) == 0)
188 else if(aSubType.CompareF(KFSSubType_FAT32) == 0)
194 SetFatSubType(fatType);
197 //------------------------------------------------------------------------------
198 /** @return FAT sub type value, which is set by SetFatSubType()*/
199 TFatSubType TVolFormatParam_FAT::FatSubType() const
201 return (TFatSubType)GetVal(KOffsetSubType);
204 //------------------------------------------------------------------------------
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"
209 void TVolFormatParam_FAT::SetSectPerCluster(TUint32 aSpc)
211 SetVal(KOffsetSpc, aSpc);
214 //------------------------------------------------------------------------------
215 /** @return value previously set by SetSectPerCluster() */
216 TUint32 TVolFormatParam_FAT::SectPerCluster() const
218 return GetVal(KOffsetSpc);
221 //------------------------------------------------------------------------------
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"
226 void TVolFormatParam_FAT::SetNumFATs(TUint32 aNumFATs)
228 SetVal(KOffsetNumFATs, aNumFATs);
231 //------------------------------------------------------------------------------
232 /** @return value previously set by SetNumFATs() */
233 TUint32 TVolFormatParam_FAT::NumFATs() const
235 return GetVal(KOffsetNumFATs);
238 //------------------------------------------------------------------------------
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"
243 void TVolFormatParam_FAT::SetReservedSectors(TUint32 aReservedSectors)
245 SetVal(KOffsetReservedSec, aReservedSectors);
248 //------------------------------------------------------------------------------
249 /** @return value previously set by SetReservedSectors() */
250 TUint32 TVolFormatParam_FAT::ReservedSectors() const
252 return GetVal(KOffsetReservedSec);
258 //------------------------------------------------------------------------------
262 }//namespace FileSystem_FAT
269 #endif //__FILESYSTEM_FAT_H__