userlibandfileserver/fileserver/sfat32/inc/sl_std.h
branchRCL_3
changeset 22 2f92ad2dc5db
parent 20 597aaf25e343
child 42 a179b74831c9
equal deleted inserted replaced
21:e7d2d738d3c2 22:2f92ad2dc5db
    62 */
    62 */
    63 class TEntryPos
    63 class TEntryPos
    64 	{
    64 	{
    65 public:
    65 public:
    66 	TEntryPos() : iCluster(EOF_32Bit), iPos(0) {}
    66 	TEntryPos() : iCluster(EOF_32Bit), iPos(0) {}
    67 	TEntryPos(TInt aCluster,TUint aPos) : iCluster(aCluster), iPos(aPos) {}
    67 	TEntryPos(TUint aCluster,TUint aPos) : iCluster(aCluster), iPos(aPos) {}
    68 
    68 
    69     inline TUint32 Cluster() const;
    69     inline TUint32 Cluster() const;
    70     inline TUint32 Pos() const;
    70     inline TUint32 Pos() const;
    71     inline TBool operator==(const TEntryPos& aRhs) const;
    71     inline TBool operator==(const TEntryPos& aRhs) const;
    72     inline void SetEndOfDir();
    72     inline void SetEndOfDir();
    73 
    73 
    74 public:
    74 public:
    75 	TInt iCluster;
    75 	TUint32 iCluster;
    76 	TUint iPos;
    76 	TUint32 iPos;
    77 	};
    77 	};
    78 
    78 
    79 
    79 
    80 /**
    80 /**
    81     Interface class between the file system and the local drive media interface,
    81     Interface class between the file system and the local drive media interface,
   202     
   202     
   203     virtual void InvalidateCacheL() {};
   203     virtual void InvalidateCacheL() {};
   204     virtual void InvalidateCacheL(TInt64 /*aPos*/,TUint32 /*aLength*/) {};
   204     virtual void InvalidateCacheL(TInt64 /*aPos*/,TUint32 /*aLength*/) {};
   205 
   205 
   206 	virtual void FreeClusterListL(TUint32 aCluster);
   206 	virtual void FreeClusterListL(TUint32 aCluster);
   207 	virtual void ExtendClusterListL(TUint32 aNumber,TInt& aCluster);
   207 	virtual void ExtendClusterListL(TUint32 aNumber, TUint32& aCluster);
   208 	
   208 	
   209     virtual TUint32 AllocateSingleClusterL(TUint32 aNearestCluster);
   209     virtual TUint32 AllocateSingleClusterL(TUint32 aNearestCluster);
   210 	virtual TUint32 AllocateClusterListL(TUint32 aNumber,TUint32 aNearestCluster);
   210 	virtual TUint32 AllocateClusterListL(TUint32 aNumber,TUint32 aNearestCluster);
   211     
   211     
   212     virtual void RequestRawWriteAccess(TInt64 /*aPos*/, TUint32 /*aLen*/) const {};
   212     virtual void RequestRawWriteAccess(TInt64 /*aPos*/, TUint32 /*aLen*/) const {};
   216     virtual TBool RequestFreeClusters(TUint32 aClustersRequired) const; 
   216     virtual TBool RequestFreeClusters(TUint32 aClustersRequired) const; 
   217 
   217 
   218     virtual void InitializeL();
   218     virtual void InitializeL();
   219     virtual TBool ConsistentState() const {return ETrue;} //-- dummy
   219     virtual TBool ConsistentState() const {return ETrue;} //-- dummy
   220 
   220 
       
   221     virtual TUint32 CountContiguousClustersL(TUint32 aStartCluster, TUint32& anEndCluster, TUint32 aMaxCount) const;
       
   222 
   221     //-----------------------------------------------------------------
   223     //-----------------------------------------------------------------
   222     //-- non-virtual interface
   224     //-- non-virtual interface
   223     TBool GetNextClusterL(TInt& aCluster) const;
   225     TBool GetNextClusterL(TUint32& aCluster) const;
   224     void WriteFatEntryEofL(TUint32 aFatIndex);
   226     void WriteFatEntryEofL(TUint32 aFatIndex);
   225 
   227 
   226     void MarkAsBadClusterL(TUint32 aCluster);
   228     void MarkAsBadClusterL(TUint32 aCluster);
   227     TInt CountContiguousClustersL(TUint32 aStartCluster,TInt& anEndCluster, TUint32 aMaxCount) const;
   229     
   228     
   230     
   229     inline TUint32 MaxEntries() const;
   231     inline TUint32 MaxEntries() const;
   230     
   232     
   231     TUint32 PosInBytes(TUint32 aFatIndex) const;	    
   233     TUint32 PosInBytes(TUint32 aFatIndex) const;	    
   232 
   234 
   514     void CheckWritableL() const;
   516     void CheckWritableL() const;
   515     void CheckStateConsistentL() const;
   517     void CheckStateConsistentL() const;
   516 
   518 
   517 	inline TBool ReadOnly(void) const;
   519 	inline TBool ReadOnly(void) const;
   518     inline void  SetReadOnly(TBool aReadOnlyMode);
   520     inline void  SetReadOnly(TBool aReadOnlyMode);
   519 	inline TInt StartCluster(const TFatDirEntry & anEntry) const;
   521 	inline TUint32 StartCluster(const TFatDirEntry & anEntry) const;
   520 	inline CRawDisk& RawDisk() const;
   522 	inline CRawDisk& RawDisk() const;
   521 	inline CFatFileSystem& FatFileSystem() const;
   523 	inline CFatFileSystem& FatFileSystem() const;
   522 	inline CFatTable& FAT() const;
   524 	inline CFatTable& FAT() const;
   523 	inline TInt ClusterSizeLog2() const;
   525 	inline TUint32 ClusterSizeLog2() const;
   524 	inline TInt SectorSizeLog2() const;
   526 	inline TUint32 SectorSizeLog2() const;
   525 	inline TInt TotalSectors() const;
   527 	inline TUint32 TotalSectors() const;
   526 	inline TInt SectorsPerCluster() const;
   528 	inline TUint32 SectorsPerCluster() const;
   527 	inline TInt ClusterBasePosition() const;
   529 	inline TUint32 ClusterBasePosition() const;
   528     inline TInt RootDirectorySector() const;
   530     inline TUint32 RootDirectorySector() const;
   529     inline TUint RootDirEnd() const;
   531     inline TUint32 RootDirEnd() const;
   530     inline TUint32 RootClusterNum() const;
   532     inline TUint32 RootClusterNum() const;
   531 
   533 
   532 	inline TFatType FatType() const;
   534 	inline TFatType FatType() const;
   533     inline TBool Is16BitFat() const;
   535     inline TBool Is16BitFat() const;
   534     inline TBool Is32BitFat() const;
   536     inline TBool Is32BitFat() const;
   535 
   537 
   536 	inline TUint32 MaxClusterNumber() const;
   538 	inline TUint32 MaxClusterNumber() const;
   537 	inline TInt StartOfFatInBytes() const;
   539 	inline TUint32 StartOfFatInBytes() const;
   538     inline TUint32 FirstFatSector() const;
   540     inline TUint32 FirstFatSector() const;
   539 
   541 
   540 	inline TInt NumberOfFats() const;
   542 	inline TUint32 NumberOfFats() const;
   541 	inline TInt FatSizeInBytes() const;
   543 	inline TUint32 FatSizeInBytes() const;
   542 	inline TInt ClusterRelativePos(TInt aPos) const;
   544 	inline TUint32 ClusterRelativePos(TUint32 aPos) const;
   543 	inline TUint StartOfRootDirInBytes() const;
   545 	inline TUint32 StartOfRootDirInBytes() const;
   544 	inline TUint32 UsableClusters() const;
   546 	inline TUint32 UsableClusters() const;
   545     inline TBool ClusterNumberValid(TUint32 aClusterNo) const;
   547     inline TBool ClusterNumberValid(TUint32 aClusterNo) const;
   546 	inline TBool IsBadCluster(TInt aCluster) const;
   548 	inline TBool IsBadCluster(TUint32 aCluster) const;
   547 	
   549 	
   548 	inline TBool IsRuggedFSys() const;
   550 	inline TBool IsRuggedFSys() const;
   549 	inline void SetRuggedFSys(TBool aVal);
   551 	inline void SetRuggedFSys(TBool aVal);
   550 	inline TUint32 AtomicWriteGranularityLog2() const;
   552 	inline TUint32 AtomicWriteGranularityLog2() const;
   551 
   553 
   552 	
   554 	
   553 	inline TInt RootIndicator() const;
   555 	inline TUint32 RootIndicator() const;
   554 	
   556 	
   555     inline TBool IsRootDir(const TEntryPos &aEntry) const;
   557     inline TBool IsRootDir(const TEntryPos &aEntry) const;
   556 	inline CAsyncNotifier* Notifier() const;
   558 	inline CAsyncNotifier* Notifier() const;
   557 	inline TDriveInterface& DriveInterface() const;
   559 	inline TDriveInterface& DriveInterface() const;
   558 
   560 
   559     inline TBool IsEndOfClusterCh(TInt aCluster) const;
   561     inline TBool IsEndOfClusterCh(TUint32 aCluster) const;
   560 	inline void SetEndOfClusterCh(TInt &aCluster) const;
   562 	inline void SetEndOfClusterCh(TUint32 &aCluster) const;
   561 
   563 
   562     
   564     
   563     void ReadUidL(TInt aCluster,TEntry& anEntry) const;
   565     void ReadUidL(TUint32 aCluster,TEntry& anEntry) const;
   564 	
   566 	
   565     void ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const;
   567     void ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const;
   566 	void WriteDirEntryL(const TEntryPos& aPos,const TFatDirEntry& aDirEntry);
   568 	void WriteDirEntryL(const TEntryPos& aPos,const TFatDirEntry& aDirEntry);
   567 
   569 
   568     void DirReadL(const TEntryPos& aPos,TInt aLength,TDes8& aDes) const;
   570     void DirReadL(const TEntryPos& aPos,TInt aLength,TDes8& aDes) const;
   569     void DirWriteL(const TEntryPos& aPos,const TDesC8& aDes);
   571     void DirWriteL(const TEntryPos& aPos,const TDesC8& aDes);
   570 
   572 
   571 	void ReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const;
   573 	void ReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const;
   572 	void WriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TInt& aBadcluster, TInt &aGoodcluster);
   574     void WriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint& aBadcluster, TUint& aGoodcluster);
       
   575 	
   573 	void MoveToNextEntryL(TEntryPos& aPos) const;
   576 	void MoveToNextEntryL(TEntryPos& aPos) const;
   574 	void MoveToDosEntryL(TEntryPos& aPos,TFatDirEntry& anEntry) const;
   577 	void MoveToDosEntryL(TEntryPos& aPos,TFatDirEntry& anEntry) const;
   575 	void EnlargeL(TInt aSize);
   578 	void EnlargeL(TInt aSize);
   576 	void ReduceSizeL(TInt aPos,TInt aLength);
   579 	void ReduceSizeL(TInt aPos,TInt aLength);
   577 	void DoDismount();
   580 	void DoDismount();
   695     void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos, XFileCreationHelper* aFileCreationHelper) const;
   698     void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos, XFileCreationHelper* aFileCreationHelper) const;
   696 
   699 
   697     void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos) const;
   700     void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos) const;
   698 
   701 
   699 	void CheckFatForLoopsL(const TFatDirEntry& anEntry) const;
   702 	void CheckFatForLoopsL(const TFatDirEntry& anEntry) const;
   700 	void DoCheckFatForLoopsL(TInt aCluster,TInt& aPreviousCluster,TInt& aChangePreviousCluster,TInt& aCount) const;
   703 	void DoCheckFatForLoopsL(TUint32 aCluster, TUint32& aPreviousCluster, TUint32& aChangePreviousCluster, TUint32& aCount) const;
   701     void InitializeL(const TLocalDriveCaps& aLocDrvCaps, TBool aIgnoreFSInfo=EFalse);
   704     void InitializeL(const TLocalDriveCaps& aLocDrvCaps, TBool aIgnoreFSInfo=EFalse);
       
   705 
   702 	void DoReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const;
   706 	void DoReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const;
   703 	void DoWriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TInt aLastcluster, TInt& aBadcluster, TInt& aGoodcluster);
   707     void DoWriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TUint aLastcluster, TUint& aBadcluster, TUint& aGoodcluster);
   704 	TBool IsUniqueNameL(const TShortName& aName,TInt aDirCluster);
   708 
       
   709 	TBool IsUniqueNameL(const TShortName& aName, TUint32 aDirCluster);
   705 	TBool FindShortNameL(const TShortName& aName,TEntryPos& anEntryPos);
   710 	TBool FindShortNameL(const TShortName& aName,TEntryPos& anEntryPos);
   706 	void ReplaceClashingNameL(const TShortName& aNewName,const TEntryPos& anEntryPos);
   711 	void ReplaceClashingNameL(const TShortName& aNewName,const TEntryPos& anEntryPos);
   707     TBool GenerateShortNameL(TInt aDirCluster,const TDesC& aLongName,TShortName& aShortName, TBool aForceRandomize=EFalse);
   712     TBool GenerateShortNameL(TUint32 aDirCluster,const TDesC& aLongName,TShortName& aShortName, TBool aForceRandomize=EFalse);
   708     TInt FindLeafDirL(const TDesC& aName, TLeafDirData& aLeafDir) const;
   713     TInt FindLeafDirL(const TDesC& aName, TLeafDirData& aLeafDir) const;
   709 	
   714 	
   710 	TInt GetDirEntry(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const;
   715 	TInt GetDirEntry(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const;
   711     TBool DoGetDirEntryL(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const;
   716     TBool DoGetDirEntryL(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const;
   712     
   717     
   713 	void WriteDirEntryL(TEntryPos& aPos,const TFatDirEntry& aFatDirEntry,const TDesC& aLongFileName);
   718 	void WriteDirEntryL(TEntryPos& aPos,const TFatDirEntry& aFatDirEntry,const TDesC& aLongFileName);
   714 	void EraseDirEntryL(TEntryPos aPos,const TFatDirEntry& anEntry);
   719 	void EraseDirEntryL(TEntryPos aPos,const TFatDirEntry& anEntry);
   715 	void EraseDirEntryL(const TEntryPos& aPos);
   720 	void EraseDirEntryL(const TEntryPos& aPos);
   716 	void InitializeFirstDirClusterL(TInt aCluster,TInt aParentCluster);
   721 	void InitializeFirstDirClusterL(TUint32 aCluster, TUint32 aParentCluster);
   717 	void AddDirEntryL(TEntryPos& aPos,TInt aNameLength);
   722 	void AddDirEntryL(TEntryPos& aPos,TInt aNameLength);
   718 	void ZeroDirClusterL(TInt aCluster);
   723 	void ZeroDirClusterL(TUint32 aCluster);
   719 	
   724 	
   720     TInt DoWriteBootSector(TInt64 aMediaPos, const TFatBootSector& aBootSector) const;
   725     TInt DoWriteBootSector(TInt64 aMediaPos, const TFatBootSector& aBootSector) const;
   721 	TInt DoReadBootSector(TInt64 aMediaPos, TFatBootSector& aBootSector) const;
   726 	TInt DoReadBootSector(TInt64 aMediaPos, TFatBootSector& aBootSector) const;
   722     TInt ReadBootSector(TFatBootSector& aBootSector, TBool aDoNotReadBkBootSec=EFalse);
   727     TInt ReadBootSector(TFatBootSector& aBootSector, TBool aDoNotReadBkBootSec=EFalse);
   723 
   728 
   724     TInt WriteFSInfoSector(TInt64 aMediaPos, const TFSInfo& aFSInfo) const;
   729     TInt WriteFSInfoSector(TInt64 aMediaPos, const TFSInfo& aFSInfo) const;
   725 	TInt ReadFSInfoSector(TInt64 aMediaPos, TFSInfo& aFSInfo) const;
   730 	TInt ReadFSInfoSector(TInt64 aMediaPos, TFSInfo& aFSInfo) const;
   726 
   731 
   727     TBool IsDirectoryEmptyL(TInt aCluster);
   732     TBool IsDirectoryEmptyL(TUint32 aCluster);
   728 	void ExtendClusterListZeroedL(TInt aNumber,TInt& aCluster);
   733 	void ExtendClusterListZeroedL(TUint32 aNumber, TUint32& aCluster);
   729 	void WritePasswordData();
   734 	void WritePasswordData();
   730 	
   735 	
   731     void WriteVolumeLabelL(const TDesC8& aVolumeLabel) const;
   736     void WriteVolumeLabelL(const TDesC8& aVolumeLabel) const;
   732     TInt ReadVolumeLabelFile(TDes8& aLabel);
   737     TInt ReadVolumeLabelFile(TDes8& aLabel);
   733 	void WriteVolumeLabelFileL(const TDesC8& aNewName);
   738 	void WriteVolumeLabelFileL(const TDesC8& aNewName);
   766 
   771 
   767     TFatType iFatType;          ///< FAT type, FAT12,16 or 32
   772     TFatType iFatType;          ///< FAT type, FAT12,16 or 32
   768     TUint32  iFatEocCode;       ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 
   773     TUint32  iFatEocCode;       ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 
   769 
   774 
   770     CLeafDirCache* iLeafDirCache;	///< A cache for most recently visited directories, only valid when limit is set bigger than 1
   775     CLeafDirCache* iLeafDirCache;	///< A cache for most recently visited directories, only valid when limit is set bigger than 1
   771     HBufC* iLastLeafDir;        	///< The last visited directory, only valid when limit of iLeafDirCache is less than 1 
       
   772     TInt iLastLeafDirCluster;   	///< Cluster number of the last visited cluster, only valid when limit of iLeafDirCache is less than 1
       
   773 
   776 
   774 	TFatVolParam iVolParam;         ///< FAT volume parameters, populated form the boot sector values.
   777 	TFatVolParam iVolParam;         ///< FAT volume parameters, populated form the boot sector values.
   775     
   778     
   776 	TInt iFirstFreeByte;            ///< First free byte in media (start of the data area on the volume)
   779 	TUint32 iFirstFreeByte;         ///< First free byte in media (start of the data area on the volume)
   777 	TUint32 iUsableClusters;        ///< Number of usable cluster on the volume 
   780 	TUint32 iUsableClusters;        ///< Number of usable cluster on the volume 
   778 	
   781 	
   779     CFatTable* iFatTable;           ///< Pointer to the volume Fat 
   782     CFatTable* iFatTable;           ///< Pointer to the volume Fat 
   780 	CRawDisk*  iRawDisk;            ///< Pointer to the raw data interface class
   783 	CRawDisk*  iRawDisk;            ///< Pointer to the raw data interface class
   781 	
   784 	
   782     CAsyncNotifier* iNotifier;  ///< Async notifier for notifying user of Fat error conditions 
   785     CAsyncNotifier* iNotifier;  ///< Async notifier for notifying user of Fat error conditions 
   783 
   786 
   784     XDriveInterface iDriverInterface; ///< the object representing interface to the drive, provides read/write access and notifiers
   787     XDriveInterface iDriverInterface; ///< the object representing interface to the drive, provides read/write access and notifiers
   785     TInt            iChkDiscRecLevel; ///< Check disk recursion level counter. A temporary measure. 
       
   786 	TFatConfig      iFatConfig;       ///< FAT parametrers from estart.txt
   788 	TFatConfig      iFatConfig;       ///< FAT parametrers from estart.txt
   787 
   789 
   788 	XFileCreationHelper iFileCreationHelper;
   790 	XFileCreationHelper iFileCreationHelper;
   789 
   791 
   790 
   792 
   812 friend class CScanDrive;
   814 friend class CScanDrive;
   813 friend class TDriveInterface;
   815 friend class TDriveInterface;
   814 	};
   816 	};
   815 
   817 
   816 
   818 
   817 
   819 //---------------------------------------------------------------------------------------------------------------------------------
   818 
   820 
   819 /**
   821 /**
   820 Fat file system file subsession implmentation, provides all that is required of a plug in
   822 Fat file system file subsession implmentation, provides all that is required of a plug in
   821 file system file as well as Fat specific functionality
   823 file system file as well as Fat specific functionality
   822 */
   824 */
   833 	void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal);
   835 	void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal);
   834 	void FlushDataL();
   836 	void FlushDataL();
   835 	void FlushAllL();
   837 	void FlushAllL();
   836 public:
   838 public:
   837 	void CheckPosL(TUint aPos);
   839 	void CheckPosL(TUint aPos);
   838 	void SetL(const TFatDirEntry& aFatDirEntry,TShare aShare,const TEntryPos& aPos);
   840 	void SetupL(const TFatDirEntry& aFatDirEntry, const TEntryPos& aFileDosEntryPos);
   839 	void CreateSeekIndex();
       
   840 	
       
   841     inline TBool IsSeekIndex() const;	
       
   842 	
   841 	
   843 	// from MBlockMapInterface
   842 	// from MBlockMapInterface
   844 	TInt BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos);
   843 	TInt BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos);
   845 
   844 
   846 	// from CFileCB
   845 	// from CFileCB
   857 	inline TInt ClusterSizeLog2();
   856 	inline TInt ClusterSizeLog2();
   858 	inline TInt ClusterRelativePos(TInt aPos);
   857 	inline TInt ClusterRelativePos(TInt aPos);
   859 
   858 
   860 
   859 
   861     void FlushStartClusterL();
   860     void FlushStartClusterL();
   862 	TInt SeekToPosition(TInt aNewCluster,TInt aClusterOffset);
   861 	TInt SeekToPosition(TUint aNewCluster, TUint aClusterOffset);
   863 	void SetSeekIndexValueL(TInt aFileCluster,TInt aStoredCluster);
   862 	void SetSeekIndexValueL(TUint aFileCluster,TUint aStoredCluster);
   864 	void ResizeIndex(TInt aNewMult,TUint aNewSize);
   863 	void ResizeIndex(TInt aNewMult,TUint aNewSize);
   865 	TInt CalcSeekIndexSize(TUint aSize);
   864 	TInt CalcSeekIndexSize(TUint aSize);
   866 	TBool IsSeekBackwards(TUint aPos);
   865 	TBool IsSeekBackwards(TUint aPos);
   867 	void ClearIndex(TUint aNewSize);
   866 	void ClearIndex(TUint aNewSize);
   868 	void DoSetSizeL(TUint aSize,TBool aIsSizeWrite);
   867 	void DoSetSizeL(TUint aSize, TBool aForceCachesFlush);
   869 	void WriteFileSizeL(TUint aSize);
   868 	void WriteFileSizeL(TUint aSize);
       
   869 
       
   870     //----------------------------
       
   871     inline TUint32 FCB_StartCluster() const;
       
   872     inline TUint32 FCB_FileSize() const; 
       
   873 
       
   874     inline void  FCB_SetStartCluster(TUint32 aVal);
       
   875     inline void  FCB_SetFileSize(TUint32 aVal);  
       
   876 
       
   877     inline TBool FileAttModified() const;
       
   878     inline void  IndicateFileAttModified(TBool aModified);
       
   879     
       
   880     inline TBool FileSizeModified() const;
       
   881     inline void  IndicateFileSizeModified(TBool aModified);
       
   882 
       
   883     inline TBool FileTimeModified() const;
       
   884     inline void  IndicateFileTimeModified(TBool aModified);
       
   885 
       
   886     //----------------------------
       
   887 
       
   888 	void CreateSeekIndex();
       
   889 
       
   890     void DoShrinkFileToZeroSizeL();
       
   891     void DoShrinkFileL(TUint32  aNewSize, TBool aForceCachesFlush);
       
   892     void DoExpandFileL(TUint32 aNewSize, TBool aForceCachesFlush);
       
   893 
   870 
   894 
   871 private:
   895 private:
   872 
   896 
   873 	TUint32* iSeekIndex;    ///< Seek index into file
   897 	TUint32* iSeekIndex;    ///< Seek index into file
   874 	TInt iSeekIndexSize;    ///< size of seek index
   898 	TInt iSeekIndexSize;    ///< size of seek index
   875 	TInt iStartCluster;     ///< Start cluster number of file
   899 	
       
   900     TUint     iStartCluster;     ///< Start cluster number of file
   876 	TEntryPos iCurrentPos;  ///< Current position in file data
   901 	TEntryPos iCurrentPos;  ///< Current position in file data
   877 	TEntryPos iFileDirPos;  ///< File directory entry position
   902 	
   878 	TBool iFileSizeModified; 
   903     TEntryPos iFileDosEntryPos;  ///< File DOS dir. entry position
       
   904 	
       
   905     TBool iFileSizeModified :1;  ///< flag, indicating that file size was modified and needs to be flushed onto the media (see FlushL())
       
   906     TBool iFileTimeModified :1;  ///< flag, indicating that file modification time was modified and needs to be flushed onto the media (see FlushL())
       
   907 
   879 	};
   908 	};
   880 
   909 
   881 
   910 
       
   911 
       
   912 //---------------------------------------------------------------------------------------------------------------------------------
   882 /**
   913 /**
   883 Fat file system directory subsession implmentation, provides all that is required of a plug in
   914 Fat file system directory subsession implmentation, provides all that is required of a plug in
   884 file system directory as well as Fat specific functionality
   915 file system directory as well as Fat specific functionality
   885 */
   916 */
   886 class CFatDirCB : public CDirCB
   917 class CFatDirCB : public CDirCB
   930 	void CreateFSInfoSectorL();
   961 	void CreateFSInfoSectorL();
   931 	void CreateReservedBootSectorL();
   962 	void CreateReservedBootSectorL();
   932 	void InitializeFormatDataL();
   963 	void InitializeFormatDataL();
   933 	void DoZeroFillMediaL(TInt64 aStartPos, TInt64 aEndPos);
   964 	void DoZeroFillMediaL(TInt64 aStartPos, TInt64 aEndPos);
   934 
   965 
   935     TInt InitFormatDataForVariableSizeDisk(TInt aDiskSizeInSectors);
   966     TInt InitFormatDataForVariableSizeDisk(TUint aDiskSizeInSectors);
   936 	TInt InitFormatDataForFixedSizeDiskNormal(TInt aDiskSizeInSectors, const TLocalDriveCapsV6& aCaps);
   967 	TInt InitFormatDataForFixedSizeDiskNormal(TUint aDiskSizeInSectors, const TLocalDriveCapsV6& aCaps);
   937 	TInt InitFormatDataForFixedSizeDiskCustom(const TLDFormatInfo& aFormatInfo);
   968 	TInt InitFormatDataForFixedSizeDiskCustom(const TLDFormatInfo& aFormatInfo);
   938     TInt InitFormatDataForFixedSizeDiskUser(TInt aDiskSizeInSectors);
   969     TInt InitFormatDataForFixedSizeDiskUser(TUint aDiskSizeInSectors);
   939 	void AdjustClusterSize(TInt aRecommendedSectorsPerCluster);
   970 	void AdjustClusterSize(TUint aRecommendedSectorsPerCluster);
   940 	TInt AdjustFirstDataSectorAlignment(TInt aBlockSize);
   971 	TInt AdjustFirstDataSectorAlignment(TUint aBlockSize);
   941 	TInt FirstDataSector() const;
   972 	TInt FirstDataSector() const;
   942 
   973 
   943 	TInt HandleCorrupt(TInt aError);
   974 	TInt HandleCorrupt(TInt aError);
   944 	TInt BadSectorToCluster();
   975 	TInt BadSectorToCluster();
   945     void TranslateL();
   976     void TranslateL();
   946     TInt DoTranslate(TPtr8& aBuf, RArray<TInt>& aArray);
   977     TInt DoTranslate(TPtr8& aBuf, RArray<TInt>& aArray);
   947     void RecordOldInfoL();
   978     void RecordOldInfoL();
   948 	TInt MaxFat12Sectors() const;
   979 	
   949 	TInt MaxFat16Sectors() const;
   980     TUint MaxFat12Sectors() const;
   950 	TUint32 MaxFat32Sectors() const;
   981 	TUint MaxFat16Sectors() const;
       
   982 	TUint MaxFat32Sectors() const;
       
   983 	
   951 	inline TBool Is16BitFat() const;
   984 	inline TBool Is16BitFat() const;
   952 	inline TBool Is32BitFat() const;
   985 	inline TBool Is32BitFat() const;
   953 	inline CFatMountCB& FatMount();
   986 	inline CFatMountCB& FatMount();
   954 	inline CProxyDrive* LocalDrive();
   987 	inline CProxyDrive* LocalDrive();
   955     TFatType SuggestFatType() const;
   988     TFatType SuggestFatType() const;
   956 
   989 
   957 private:
   990 private:
   958 	
   991 	
   959     TBool   iVariableSize;      ///< Flag to indicat if we are dealing with a variable size volume
   992     TBool   iVariableSize;      ///< Flag to indicat if we are dealing with a variable size volume
   960 	TInt    iBytesPerSector;    ///< Byte per sector of media
   993 	
       
   994     TUint16 iBytesPerSector;    ///< Byte per sector of media
   961     TInt    iSectorSizeLog2;    ///< Sector size in log2
   995     TInt    iSectorSizeLog2;    ///< Sector size in log2
   962 	TInt    iNumberOfFats;      ///< Number of Fats the volume will contain
   996 	TUint8  iNumberOfFats;      ///< Number of Fats the volume will contain
   963 	TInt    iReservedSectors;   ///< Number of reserved sectors in the volume
   997 	TUint   iReservedSectors;   ///< Number of reserved sectors in the volume
   964 	TInt    iRootDirEntries;    ///< Nummer of root directory entries the root dir will have, specific to Fat12/16 volumes
   998 	TUint16 iRootDirEntries;    ///< Nummer of root directory entries the root dir will have, specific to Fat12/16 volumes
   965 	TInt    iSectorsPerCluster; ///< Sector per cluster ration the volume will be formatted with
   999 	TUint   iSectorsPerCluster; ///< Sector per cluster ration the volume will be formatted with
   966 	TInt    iSectorsPerFat;     ///< Number of sectors the Fat uses
  1000 	TUint   iSectorsPerFat;     ///< Number of sectors the Fat uses
   967 	TInt    iMaxDiskSectors;    ///< number of sectors the volume has
  1001 	TUint32 iMaxDiskSectors;    ///< number of sectors the volume has
   968 	TFormatInfo iFormatInfo;    ///< format information for a custom format
  1002 	TFormatInfo iFormatInfo;    ///< format information for a custom format
   969 	TBuf8<16>   iFileSystemName;///< Buffer to contain the volume name 
  1003 	TBuf8<16>   iFileSystemName;///< Buffer to contain the volume name 
   970 	TInt    iHiddenSectors;     ///< Number of hidden sectors in the volume
  1004 	TInt    iHiddenSectors;     ///< Number of hidden sectors in the volume
   971 	TInt    iNumberOfHeads;     ///< Number of heads the media device has, not used so far as only used on solid state media.
  1005 	TUint16 iNumberOfHeads;     ///< Number of heads the media device has, not used so far as only used on solid state media.
   972 	TInt    iSectorsPerTrack;   ///< Number of sectors the media device has, not used so far as only used on solid state media.
  1006 	TUint16 iSectorsPerTrack;   ///< Number of sectors the media device has, not used so far as only used on solid state media.
   973 	TUint32 iRootClusterNum;    ///< cluster number used for root directory, Fat32 specific
  1007 	TUint32 iRootClusterNum;    ///< cluster number used for root directory, Fat32 specific
   974 	TUint32 iCountOfClusters;   ///< Count of clusters on the media
  1008 	TUint32 iCountOfClusters;   ///< Count of clusters on the media
   975     RArray<TInt> iBadClusters;  ///< Array of bad cluster numbers
  1009     RArray<TInt> iBadClusters;  ///< Array of bad cluster numbers
   976     RArray<TInt> iBadSectors;   ///< Array of bad sector numbers
  1010     RArray<TInt> iBadSectors;   ///< Array of bad sector numbers
   977     TBool   iDiskCorrupt;       ///< Disk is corrupt when format or not
  1011     TBool   iDiskCorrupt;       ///< Disk is corrupt when format or not