77 Interface class between the file system and the local drive media interface, |
77 Interface class between the file system and the local drive media interface, |
78 handles incomplete writes to media with the ability to notify the user. |
78 handles incomplete writes to media with the ability to notify the user. |
79 This class can't be instantinated by user; only CFatMountCB can do this; see CFatMountCB::DriveInterface() |
79 This class can't be instantinated by user; only CFatMountCB can do this; see CFatMountCB::DriveInterface() |
80 |
80 |
81 */ |
81 */ |
82 class TFatDriveInterface |
82 class TDriveInterface |
83 { |
83 { |
84 public: |
84 public: |
85 enum TAction {ERetry=1}; |
85 enum TAction {ERetry=1}; |
86 |
86 |
87 public: |
87 public: |
104 //-- release the mutex guarding CProxyDrive. |
104 //-- release the mutex guarding CProxyDrive. |
105 inline void ReleaseLock() const {iProxyDrive.LeaveCriticalSection();} |
105 inline void ReleaseLock() const {iProxyDrive.LeaveCriticalSection();} |
106 |
106 |
107 |
107 |
108 protected: |
108 protected: |
109 TFatDriveInterface(); |
109 TDriveInterface(); |
110 TFatDriveInterface(const TFatDriveInterface&); |
110 TDriveInterface(const TDriveInterface&); |
111 TFatDriveInterface& operator=(const TFatDriveInterface&); |
111 TDriveInterface& operator=(const TDriveInterface&); |
112 |
112 |
113 TBool Init(CFatMountCB* aMount); |
113 TBool Init(CFatMountCB* aMount); |
114 void Close(); |
114 void Close(); |
115 |
115 |
116 inline TBool NotifyUser() const; |
116 inline TBool NotifyUser() const; |
136 TBool Init(CProxyDrive* aProxyDrive); |
136 TBool Init(CProxyDrive* aProxyDrive); |
137 |
137 |
138 inline void EnterCriticalSection() const {iLock.Wait();} |
138 inline void EnterCriticalSection() const {iLock.Wait();} |
139 inline void LeaveCriticalSection() const {iLock.Signal();} |
139 inline void LeaveCriticalSection() const {iLock.Signal();} |
140 |
140 |
141 //-- methods' wrappers that are used by TFatDriveInterface |
141 //-- methods' wrappers that are used by TDriveInterface |
142 TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const; |
142 TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const; |
143 TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const; |
143 TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const; |
144 TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset); |
144 TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset); |
145 TInt Write(TInt64 aPos, const TDesC8& aSrc); |
145 TInt Write(TInt64 aPos, const TDesC8& aSrc); |
146 TInt GetLastErrorInfo(TDes8& aErrorInfo) const; |
146 TInt GetLastErrorInfo(TDes8& aErrorInfo) const; |
241 |
241 |
242 |
242 |
243 inline TInt SectorSizeLog2() const; |
243 inline TInt SectorSizeLog2() const; |
244 inline TUint32 FreeClusters() const; |
244 inline TUint32 FreeClusters() const; |
245 |
245 |
246 inline TBool IsEof32Bit(TInt aCluster) const; |
246 inline TBool IsEndOfClusterCh(TUint32 aCluster) const; |
247 inline TBool IsEof16Bit(TInt aCluster) const; |
247 |
248 inline TBool IsEof12Bit(TInt aCluster) const; |
|
249 |
|
250 |
248 |
251 inline TFatType FatType() const; |
249 inline TFatType FatType() const; |
252 inline TBool IsFat12() const; |
250 inline TBool IsFat12() const; |
253 inline TBool IsFat16() const; |
251 inline TBool IsFat16() const; |
254 inline TBool IsFat32() const; |
252 inline TBool IsFat32() const; |
|
253 |
255 |
254 |
256 inline TBool ClusterNumberValid(TUint32 aClusterNo) const; |
255 inline TBool ClusterNumberValid(TUint32 aClusterNo) const; |
257 |
256 |
258 typedef RArray<TUint> RClusterArray; |
257 typedef RArray<TUint> RClusterArray; |
259 void DoFreedClustersNotify(RClusterArray &aFreedClusters); |
258 void DoFreedClustersNotify(RClusterArray &aFreedClusters); |
267 private: |
266 private: |
268 |
267 |
269 TUint32 iFreeClusters; ///< Number of free cluster in the fat table |
268 TUint32 iFreeClusters; ///< Number of free cluster in the fat table |
270 TUint32 iFreeClusterHint; ///< this is just a hint to the free cluster number, not required to contain exact information. |
269 TUint32 iFreeClusterHint; ///< this is just a hint to the free cluster number, not required to contain exact information. |
271 TFatType iFatType; ///< FAT type 12/16/32, cached from the iOwner |
270 TFatType iFatType; ///< FAT type 12/16/32, cached from the iOwner |
|
271 TUint32 iFatEocCode; ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 |
272 TUint32 iMaxEntries; ///< maximal number of FAT entries in the table. This value is taken from the CFatMount that calculates it |
272 TUint32 iMaxEntries; ///< maximal number of FAT entries in the table. This value is taken from the CFatMount that calculates it |
273 |
273 |
274 }; |
274 }; |
275 |
275 |
276 |
276 |
485 inline void SetState(TFatMntState aState); |
485 inline void SetState(TFatMntState aState); |
486 TInt OpenMountForWrite(); |
486 TInt OpenMountForWrite(); |
487 TInt IsFinalised(TBool& aFinalised); |
487 TInt IsFinalised(TBool& aFinalised); |
488 |
488 |
489 /** |
489 /** |
490 A wrapper around TFatDriveInterface providing its instantination and destruction. |
490 A wrapper around TDriveInterface providing its instantination and destruction. |
491 You must not create objects of this class, use DriveInterface() instead. |
491 You must not create objects of this class, use DriveInterface() instead. |
492 */ |
492 */ |
493 class XDriveInterface: public TFatDriveInterface |
493 class XDriveInterface: public TDriveInterface |
494 { |
494 { |
495 public: |
495 public: |
496 XDriveInterface() : TFatDriveInterface() {} |
496 XDriveInterface() : TDriveInterface() {} |
497 ~XDriveInterface() {Close();} |
497 ~XDriveInterface() {Close();} |
498 TBool Init(CFatMountCB* aMount) {return TFatDriveInterface::Init(aMount);} |
498 TBool Init(CFatMountCB* aMount) {return TDriveInterface::Init(aMount);} |
499 }; |
499 }; |
500 |
500 |
501 |
501 |
502 public: |
502 public: |
503 |
503 |
541 |
541 |
542 inline TInt RootIndicator() const; |
542 inline TInt RootIndicator() const; |
543 |
543 |
544 inline TBool IsRootDir(const TEntryPos &aEntry) const; |
544 inline TBool IsRootDir(const TEntryPos &aEntry) const; |
545 inline CAsyncNotifier* Notifier() const; |
545 inline CAsyncNotifier* Notifier() const; |
546 inline TFatDriveInterface& DriveInterface() const; |
546 inline TDriveInterface& DriveInterface() const; |
|
547 |
|
548 inline TBool IsEndOfClusterCh(TInt aCluster) const; |
|
549 inline void SetEndOfClusterCh(TInt &aCluster) const; |
|
550 |
547 |
551 |
548 void ReadUidL(TInt aCluster,TEntry& anEntry) const; |
552 void ReadUidL(TInt aCluster,TEntry& anEntry) const; |
549 |
553 |
550 void ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const; |
554 void ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const; |
551 void WriteDirEntryL(const TEntryPos& aPos,const TFatDirEntry& aDirEntry); |
555 void WriteDirEntryL(const TEntryPos& aPos,const TFatDirEntry& aDirEntry); |
565 |
569 |
566 void DoRenameOrReplaceL(const TDesC& anOldName,const TDesC& aNewName,TRenMode aMode,TEntryPos& aNewPos); |
570 void DoRenameOrReplaceL(const TDesC& anOldName,const TDesC& aNewName,TRenMode aMode,TEntryPos& aNewPos); |
567 void FindDosNameL(const TDesC& aName,TUint anAtt,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName,TInt anError) const; |
571 void FindDosNameL(const TDesC& aName,TUint anAtt,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName,TInt anError) const; |
568 |
572 |
569 void Dismount(); |
573 void Dismount(); |
570 TBool IsEndOfClusterCh(TInt aCluster) const; |
574 |
571 void SetEndOfClusterCh(TInt &aCluster) const; |
575 void InitializeRootEntry(TFatDirEntry & anEntry) const; |
572 void InitializeRootEntry(TFatDirEntry & anEntry) const; |
|
573 |
576 |
574 TInt64 MakeLinAddrL(const TEntryPos& aPos) const; |
577 TInt64 MakeLinAddrL(const TEntryPos& aPos) const; |
575 |
578 |
576 inline const TFatConfig& FatConfig() const; |
579 inline const TFatConfig& FatConfig() const; |
577 TBool CheckVolumeTheSame(); |
580 TBool CheckVolumeTheSame(); |
709 TBool VolCleanFlagSupported() const; |
712 TBool VolCleanFlagSupported() const; |
710 |
713 |
711 void DoUpdateFSInfoSectorsL(TBool aInvalidateFSInfo); |
714 void DoUpdateFSInfoSectorsL(TBool aInvalidateFSInfo); |
712 void UnFinaliseMountL(); |
715 void UnFinaliseMountL(); |
713 void DoReMountL(); |
716 void DoReMountL(); |
|
717 void SetFatType(TFatType aFatType); |
|
718 |
714 |
719 |
715 private: |
720 private: |
716 |
721 |
717 TBool ValidClusterNumber(TUint32 aCluster) const; |
722 TBool ValidClusterNumber(TUint32 aCluster) const; |
718 void CheckUnvisitedClustersL(const RBitVector& aFatBitVec) const; |
723 void CheckUnvisitedClustersL(const RBitVector& aFatBitVec) const; |
732 TBool iReadOnly : 1;///< if true, the drive is in read-only mode |
737 TBool iReadOnly : 1;///< if true, the drive is in read-only mode |
733 TBool iRamDrive : 1;///< true if this is a RAM drive |
738 TBool iRamDrive : 1;///< true if this is a RAM drive |
734 TBool iMainBootSecValid : 1;///< true if the main boot sector is valid, if false, a backup boot sector may be in use. |
739 TBool iMainBootSecValid : 1;///< true if the main boot sector is valid, if false, a backup boot sector may be in use. |
735 |
740 |
736 TFatMntState iState; ///< this mounnt internal state |
741 TFatMntState iState; ///< this mounnt internal state |
|
742 |
737 TFatType iFatType; ///< FAT type, FAT12,16 or 32 |
743 TFatType iFatType; ///< FAT type, FAT12,16 or 32 |
|
744 TUint32 iFatEocCode; ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32 |
738 |
745 |
739 CLeafDirCache* iLeafDirCache; ///< A cache for most recently visited directories, only valid when limit is set bigger than 1 |
746 CLeafDirCache* iLeafDirCache; ///< A cache for most recently visited directories, only valid when limit is set bigger than 1 |
740 HBufC* iLastLeafDir; ///< The last visited directory, only valid when limit of iLeafDirCache is less than 1 |
747 HBufC* iLastLeafDir; ///< The last visited directory, only valid when limit of iLeafDirCache is less than 1 |
741 TInt iLastLeafDirCluster; ///< Cluster number of the last visited cluster, only valid when limit of iLeafDirCache is less than 1 |
748 TInt iLastLeafDirCluster; ///< Cluster number of the last visited cluster, only valid when limit of iLeafDirCache is less than 1 |
742 |
749 |
839 |
846 |
840 private: |
847 private: |
841 |
848 |
842 TUint32* iSeekIndex; ///< Seek index into file |
849 TUint32* iSeekIndex; ///< Seek index into file |
843 TInt iSeekIndexSize; ///< size of seek index |
850 TInt iSeekIndexSize; ///< size of seek index |
844 TBool iAttPending; |
|
845 TInt iStartCluster; ///< Start cluster number of file |
851 TInt iStartCluster; ///< Start cluster number of file |
846 TEntryPos iCurrentPos; ///< Current position in file data |
852 TEntryPos iCurrentPos; ///< Current position in file data |
847 TEntryPos iFileDirPos; ///< File directory entry position |
853 TEntryPos iFileDirPos; ///< File directory entry position |
848 TBool iFileSizeModified; |
854 TBool iFileSizeModified; |
849 }; |
855 }; |
850 // |
856 |
851 |
857 |
852 /** |
858 /** |
853 Fat file system directory subsession implmentation, provides all that is required of a plug in |
859 Fat file system directory subsession implmentation, provides all that is required of a plug in |
854 file system directory as well as Fat specific functionality |
860 file system directory as well as Fat specific functionality |
855 */ |
861 */ |
961 TInt Install(); |
967 TInt Install(); |
962 CMountCB* NewMountL() const; |
968 CMountCB* NewMountL() const; |
963 CFileCB* NewFileL() const; |
969 CFileCB* NewFileL() const; |
964 CDirCB* NewDirL() const; |
970 CDirCB* NewDirL() const; |
965 CFormatCB* NewFormatL() const; |
971 CFormatCB* NewFormatL() const; |
966 void DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const; |
|
967 TInt DefaultPath(TDes& aPath) const; |
972 TInt DefaultPath(TDes& aPath) const; |
968 TBool IsExtensionSupported() const; |
973 TBool IsExtensionSupported() const; |
969 TBool GetUseLocalTime() const; |
974 TBool GetUseLocalTime() const; |
970 void SetUseLocalTime(TBool aFlag); |
975 void SetUseLocalTime(TBool aFlag); |
971 TInt GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput); |
976 TInt GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput); |
997 // |
1002 // |
998 |
1003 |
999 TPtrC RemoveTrailingDots(const TDesC& aName); |
1004 TPtrC RemoveTrailingDots(const TDesC& aName); |
1000 |
1005 |
1001 /** |
1006 /** |
1002 Indicates if a number passed in is a power of two |
|
1003 @return ETrue if aVal is a power of 2 |
|
1004 */ |
|
1005 inline TBool IsPowerOf2(TUint32 aVal); |
|
1006 |
|
1007 /** |
|
1008 Calculates the log2 of a number |
1007 Calculates the log2 of a number |
1009 |
1008 |
1010 @param aNum Number to calulate the log two of |
1009 @param aNum Number to calulate the log two of |
1011 @return The log two of the number passed in |
1010 @return The log two of the number passed in |
1012 */ |
1011 */ |
1013 TUint32 Log2(TUint32 aVal); |
1012 TUint32 Log2(TUint32 aVal); |
1014 |
|
1015 /** @return 2^aVal*/ |
|
1016 inline TUint32 Pow2(TUint32 aVal); |
|
1017 |
1013 |
1018 |
1014 |
1019 /** |
1015 /** |
1020 Converts Dos time (from a directory entry) to TTime format |
1016 Converts Dos time (from a directory entry) to TTime format |
1021 |
1017 |