imgtools/imglib/filesystem/include/fat32filesystem.h
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * FAT32 file system Class for FileSystem component
       
    16 * @internalComponent
       
    17 * @released
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef FAT32FILESYSTEM_H
       
    23 #define FAT32FILESYSTEM_H
       
    24 
       
    25 #include "filesystemclass.h"
       
    26 #include "errorhandler.h"
       
    27 #include "dirregion.h"
       
    28 #include "filesysteminterface.h"
       
    29 
       
    30 // constant values to initialize FSInfo data structure
       
    31 const unsigned int KFSIleadSign=0x41615252;
       
    32 const unsigned int KFSIStrutSign=0x61417272;
       
    33 const unsigned int KFSIFreeCount=0xFFFFFFFF;
       
    34 const unsigned int KFSITrailSign=0xAA550000;
       
    35 
       
    36 //sector number containing copy of FAT Table and Boot sector
       
    37 const unsigned int KBootBackupSector=6;
       
    38 const unsigned int KFatBackupSector=7;
       
    39 
       
    40 /**
       
    41 Class representing FSINFO DataStrcuture
       
    42 
       
    43 @internalComponent
       
    44 @released
       
    45 */
       
    46 class FSInfo
       
    47 {
       
    48 
       
    49 public: 
       
    50 	void SetFSInfo();
       
    51 public:
       
    52 	//lead signature use to validate a FSInfo structure
       
    53 	unsigned int FSI_LeadSign;
       
    54 	//field for future expansion
       
    55 	unsigned char FSI_Reserved[KFSIFutureExpansion];
       
    56 	//another signature
       
    57 	unsigned int FSI_StrucSig;
       
    58 	//contains the last known free cluster count on the  volume
       
    59 	unsigned int FSI_Free_Count;
       
    60 	//indicates the cluster number at which the driver should start looking for free clusters
       
    61 	unsigned int FSI_Nxt_Free;
       
    62 	//reserved for future expansion
       
    63 	unsigned int FSI_Reserved2[KFSIKFSIFutureExpansion2];
       
    64 	//use to validate that this is an fact an FSInfo sector
       
    65 	unsigned int FSI_TrailSig;
       
    66 
       
    67 };
       
    68 
       
    69 // Use to initialize the FSInfo data structure
       
    70 inline void FSInfo::SetFSInfo()
       
    71 {
       
    72 	FSI_LeadSign=KFSIleadSign;
       
    73 	for(int i=0;i<KFSIFutureExpansion;i++)
       
    74 		FSI_Reserved[i]=0;
       
    75 	FSI_StrucSig=KFSIStrutSign;
       
    76 	FSI_Free_Count=KFSIFreeCount;
       
    77 	FSI_Nxt_Free=KFSIFreeCount;
       
    78 	for(int j=0;j<KFSIKFSIFutureExpansion2;j++)
       
    79 		FSI_Reserved2[j]=0;
       
    80 	FSI_TrailSig=KFSITrailSign;
       
    81 }
       
    82 /**
       
    83 Class representing concrete class representing FAT32 type 
       
    84 @internalComponent
       
    85 @released
       
    86 */
       
    87 class CFat32FileSystem : public CFileSystem
       
    88 {
       
    89 public:
       
    90 	CFat32FileSystem(){};
       
    91 	~CFat32FileSystem();
       
    92 
       
    93 public:
       
    94 	void CreateBootSector(Long64 aPartitionSize,ConfigurableFatAttributes* aConfigurableFatAttributes);
       
    95 	void WriteBootSector(ofstream& aOutPutStream);
       
    96 	void CreateFatTable(ofstream& aOutPutStream);
       
    97 	void CreateFSinfoSector(ofstream& aOutPutStream);
       
    98 	void RestReservedSectors(ofstream& aOutPutStream);
       
    99 	void ComputeClusterSizeInBytes();
       
   100 	void ComputeRootDirSectors();
       
   101 	void ComputeBytesPerSector();
       
   102 	void ComputeTotalClusters(Long64 aPartitionSize);
       
   103 	void Execute(Long64 aPartitionSize,EntryList aNodeList,
       
   104 				ofstream& aOutPutStream,ConfigurableFatAttributes* aConfigurableFatAttributes);
       
   105 	void ErrorExceptionClean();
       
   106 
       
   107 private:
       
   108 	TFAT32BootSector iFAT32BootSector;
       
   109 	//use to contain the data structure used to create a FAT Table
       
   110 	TClustersPerEntryMap* iClustersPerEntry;
       
   111 	FSInfo iFSInfo; //FSInfo data structure
       
   112 	//Pointer to dynamic array representing the content of FSInfo data structure
       
   113 	unsigned char* FSinfoData;
       
   114 };
       
   115 
       
   116 #endif //FAT32FILESYSTEM_H