sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: // Public header file for "FAT" file system. Contains this file system name and optional file system - specific declarations. sl@0: // sl@0: // sl@0: // sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: #if !defined(__FILESYSTEM_FAT_H__) sl@0: #define __FILESYSTEM_FAT_H__ sl@0: sl@0: sl@0: #if !defined(__F32FILE_H__) sl@0: #include sl@0: #endif sl@0: sl@0: sl@0: sl@0: /** sl@0: FAT filesystem name, which shall be provided to RFs::MountFileSystem() and is returned by RFs::FileSystemName() if sl@0: this file system is mounted on the drive. The literal is case-insensitive. sl@0: @see RFs::MountFileSystem() sl@0: @see RFs::FileSystemName() sl@0: */ sl@0: _LIT(KFileSystemName_FAT, "FAT"); sl@0: sl@0: /** sl@0: FAT file system subtypes, literal values. These values are returned by RFs::FileSystemSubType(). sl@0: The literals are case-insensitive. sl@0: File sytem "FAT" mounted on the drive can be one of the FAT12/FAT16/FAT32 sl@0: sl@0: @see RFs::::FileSystemSubType() sl@0: */ sl@0: _LIT(KFSSubType_FAT12, "FAT12"); ///< corresponds to FAT12 sl@0: _LIT(KFSSubType_FAT16, "FAT16"); ///< corresponds to FAT16 sl@0: _LIT(KFSSubType_FAT32, "FAT32"); ///< corresponds to FAT32 sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: sl@0: namespace FileSystem_FAT sl@0: { sl@0: sl@0: /** Numeric representation of FAT file system sub types */ sl@0: enum TFatSubType sl@0: { sl@0: EInvalid = 0, ///< invalid terminal value sl@0: ENotSpecified = 0, ///< not specified sl@0: sl@0: EFat12 = 12, ///< corresponds to FAT12 sl@0: EFat16 = 16, ///< corresponds to FAT16 sl@0: EFat32 = 32 ///< corresponds to FAT32 sl@0: }; sl@0: sl@0: sl@0: const TUint64 KMaxSupportedFatFileSize = 0xFFFFFFFF; ///< theoretical maximum file size supported by all FAT filesystems (4GB-1) sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: sl@0: /** sl@0: This class describes specific parameters for formatting volume with FAT file system. sl@0: The parameters are: FAT sub type (FAT12/16/32), Number of Sectors per cluster, Number of FAT tables, Number of reserved sectors. sl@0: All parameters are optional and if not set, it is up to the file system implementation to decide values. sl@0: sl@0: This class package (TVolFormatParam_FATBuf) shall be passed to the RFormat::Open() as "Special format information" sl@0: sl@0: Please note that the parameters may have invalid combinations and it is not always possible to format volume with the specified sl@0: FAT sub type, like FAT12. In this case RFormat::Open() will return corresponding error code (the concrete code depends on file system implementation). sl@0: sl@0: RFormat::Open() does not modify any data in this structure. sl@0: sl@0: @see TVolFormatParam_FATBuf sl@0: @see RFormat::Open() sl@0: */ sl@0: class TVolFormatParam_FAT : public TVolFormatParam sl@0: { sl@0: public: sl@0: inline TVolFormatParam_FAT(); sl@0: inline void Init(); sl@0: sl@0: inline void SetFatSubType(TFatSubType aSubType); sl@0: inline void SetFatSubType(const TDesC& aSubType); sl@0: inline TFatSubType FatSubType() const; sl@0: //-- sl@0: inline void SetSectPerCluster(TUint32 aSpc); sl@0: inline TUint32 SectPerCluster() const; sl@0: //-- sl@0: inline void SetNumFATs(TUint32 aNumFATs); sl@0: inline TUint32 NumFATs() const; sl@0: sl@0: //-- sl@0: inline void SetReservedSectors(TUint32 aReservedSectors); sl@0: inline TUint32 ReservedSectors() const; sl@0: sl@0: sl@0: private: sl@0: void SetFileSystemName(const TDesC& aFsName); sl@0: sl@0: enum ///< offsets of the data units in parent class container sl@0: { sl@0: KOffsetSubType =0, //-- 0 sl@0: KOffsetReservedSec, //-- 1 sl@0: KOffsetSpc, //-- 2 !! do not change this offset. sl@0: KOffsetNumFATs, //-- 3 !! do not change this offset. sl@0: sl@0: }; sl@0: sl@0: }; //TVolFormatParam_FAT sl@0: sl@0: sl@0: /** sl@0: TVolFormatParam_FAT package buffer to be passed to RFormat::Open(). sl@0: @see TVolFormatParam_FAT sl@0: @see RFormat::Open() sl@0: */ sl@0: typedef TPckgBuf TVolFormatParam_FATBuf; sl@0: sl@0: sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: //-- inline functions sl@0: //------------------------------------------------------------------------------ sl@0: sl@0: TVolFormatParam_FAT::TVolFormatParam_FAT() : TVolFormatParam() sl@0: { sl@0: __ASSERT_COMPILE(sizeof(TVolFormatParam_FAT) == sizeof(TVolFormatParam)); sl@0: __ASSERT_COMPILE(KOffsetSpc == 2); sl@0: __ASSERT_COMPILE(KOffsetNumFATs == 3); sl@0: sl@0: Init(); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** initialises the data structure with default values for all parameters and automatically sets file system name as "FAT" */ sl@0: void TVolFormatParam_FAT::Init() sl@0: { sl@0: TVolFormatParam::Init(); sl@0: TVolFormatParam::SetFileSystemName(KFileSystemName_FAT); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** sl@0: Set desired FAT subtype. sl@0: @param aSubType specifies FAT12/16/32 subtype. Value 0 means "the file system will decide itself what to use" sl@0: */ sl@0: void TVolFormatParam_FAT::SetFatSubType(TFatSubType aSubType) sl@0: { sl@0: ASSERT(aSubType == ENotSpecified || aSubType == EFat12 || aSubType == EFat16 || aSubType == EFat32); sl@0: SetVal(KOffsetSubType, aSubType); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** sl@0: Set desired FAT subtype using string literals, @see KFSSubType_FAT12, @see KFSSubType_FAT16, @see KFSSubType_FAT32 sl@0: @param aSubType string descriptor, like "FAT16" sl@0: */ sl@0: void TVolFormatParam_FAT::SetFatSubType(const TDesC& aSubType) sl@0: { sl@0: TFatSubType fatType = ENotSpecified; sl@0: sl@0: if(aSubType.CompareF(KFSSubType_FAT12) == 0) sl@0: fatType = EFat12; sl@0: else if(aSubType.CompareF(KFSSubType_FAT16) == 0) sl@0: fatType = EFat16; sl@0: else if(aSubType.CompareF(KFSSubType_FAT32) == 0) sl@0: fatType = EFat32; sl@0: else sl@0: { ASSERT(0);} sl@0: sl@0: sl@0: SetFatSubType(fatType); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** @return FAT sub type value, which is set by SetFatSubType()*/ sl@0: TFatSubType TVolFormatParam_FAT::FatSubType() const sl@0: { sl@0: return (TFatSubType)GetVal(KOffsetSubType); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** sl@0: Set Number of "Sectors per cluster". For valid values see FAT specs. sl@0: @param aSpc Number of "Sectors per cluster". Value 0 means "the file system will decide itself what to use" sl@0: */ sl@0: void TVolFormatParam_FAT::SetSectPerCluster(TUint32 aSpc) sl@0: { sl@0: SetVal(KOffsetSpc, aSpc); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** @return value previously set by SetSectPerCluster() */ sl@0: TUint32 TVolFormatParam_FAT::SectPerCluster() const sl@0: { sl@0: return GetVal(KOffsetSpc); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** sl@0: Set Number of FAT tables on the volume. The maximum is supported by the FAT FS implementation is 2 sl@0: @param aNumFATs Number of FAT tables. Value 0 means "the file system will decide itself what to use" sl@0: */ sl@0: void TVolFormatParam_FAT::SetNumFATs(TUint32 aNumFATs) sl@0: { sl@0: SetVal(KOffsetNumFATs, aNumFATs); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** @return value previously set by SetNumFATs() */ sl@0: TUint32 TVolFormatParam_FAT::NumFATs() const sl@0: { sl@0: return GetVal(KOffsetNumFATs); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** sl@0: Set number of reserved sectors on FAT volume. The file system will validate this parameter before formatting. sl@0: @param aReservedSectors number of reserved sectors. Value 0 means "the file system will decide itself what to use" sl@0: */ sl@0: void TVolFormatParam_FAT::SetReservedSectors(TUint32 aReservedSectors) sl@0: { sl@0: SetVal(KOffsetReservedSec, aReservedSectors); sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: /** @return value previously set by SetReservedSectors() */ sl@0: TUint32 TVolFormatParam_FAT::ReservedSectors() const sl@0: { sl@0: return GetVal(KOffsetReservedSec); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: //------------------------------------------------------------------------------ sl@0: sl@0: sl@0: sl@0: }//namespace FileSystem_FAT sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: #endif //__FILESYSTEM_FAT_H__ sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: