29 |
29 |
30 #include "common.h" |
30 #include "common.h" |
31 #include <f32ver.h> |
31 #include <f32ver.h> |
32 #include <e32svr.h> |
32 #include <e32svr.h> |
33 #include <kernel/localise.h> |
33 #include <kernel/localise.h> |
|
34 |
34 #include "filesystem_fat.h" |
35 #include "filesystem_fat.h" |
|
36 using namespace FileSystem_FAT; |
35 |
37 |
36 #include "common_constants.h" |
38 #include "common_constants.h" |
37 #include "sl_bpb.h" |
39 #include "sl_bpb.h" |
38 #include "fat_config.h" |
40 #include "fat_config.h" |
39 #include "fat_dir_entry.h" |
41 #include "fat_dir_entry.h" |
40 |
42 #include "bit_vector.h" |
41 using namespace FileSystem_FAT; |
43 |
|
44 |
42 |
45 |
43 #ifdef _DEBUG |
46 #ifdef _DEBUG |
44 _LIT(KThisFsyName,"EFAT32.FSY"); ///< This FSY name |
47 _LIT(KThisFsyName,"EFAT32.FSY"); ///< This FSY name |
45 #endif |
48 #endif |
46 |
49 |
999 static void ConvertToUnicodeL(TDes16& aUnicode, const TDesC8& aForeign, TFatUtilityFunctions::TOverflowAction aOverflowAction=TFatUtilityFunctions::EOverflowActionTruncate); |
997 static void ConvertToUnicodeL(TDes16& aUnicode, const TDesC8& aForeign, TFatUtilityFunctions::TOverflowAction aOverflowAction=TFatUtilityFunctions::EOverflowActionTruncate); |
1000 static TBool IsLegalShortNameCharacter(TUint aCharacter,TBool aUseExtendedChars=EFalse); |
998 static TBool IsLegalShortNameCharacter(TUint aCharacter,TBool aUseExtendedChars=EFalse); |
1001 }; |
999 }; |
1002 // |
1000 // |
1003 |
1001 |
1004 TPtrC RemoveTrailingDots(const TDesC& aName); |
|
1005 |
|
1006 /** |
|
1007 Calculates the log2 of a number |
|
1008 |
|
1009 @param aNum Number to calulate the log two of |
|
1010 @return The log two of the number passed in |
|
1011 */ |
|
1012 TUint32 Log2(TUint32 aVal); |
|
1013 |
|
1014 |
|
1015 /** |
1002 /** |
1016 Converts Dos time (from a directory entry) to TTime format |
1003 Converts Dos time (from a directory entry) to TTime format |
1017 |
1004 |
1018 @param aDosTime Dos format time |
1005 @param aDosTime Dos format time |
1019 @param aDosDate Dos format Date |
1006 @param aDosDate Dos format Date |
1068 @return the checksum |
1055 @return the checksum |
1069 */ |
1056 */ |
1070 TUint8 CalculateShortNameCheckSum(const TDesC8& aShortName); |
1057 TUint8 CalculateShortNameCheckSum(const TDesC8& aShortName); |
1071 |
1058 |
1072 TUint32 EocCodeByFatType(TFatType aFatType); |
1059 TUint32 EocCodeByFatType(TFatType aFatType); |
1073 |
|
1074 |
|
1075 |
|
1076 //----------------------------------------------------------------------------- |
|
1077 |
|
1078 /** |
|
1079 This class represents a bit vector i.e. an array of bits. Vector size can be 1..2^32 bits. |
|
1080 */ |
|
1081 class RBitVector |
|
1082 { |
|
1083 public: |
|
1084 |
|
1085 RBitVector(); //-- Creates an empty vector. see Create() methods for memory allocation |
|
1086 ~RBitVector(); |
|
1087 |
|
1088 void Close(); |
|
1089 |
|
1090 TInt Create(TUint32 aNumBits); |
|
1091 void CreateL(TUint32 aNumBits); |
|
1092 |
|
1093 inline TUint32 Size() const; |
|
1094 |
|
1095 //-- single bit manipulation methods |
|
1096 inline TBool operator[](TUint32 aIndex) const; |
|
1097 inline void SetBit(TUint32 aIndex); |
|
1098 inline void ResetBit(TUint32 aIndex); |
|
1099 inline void InvertBit(TUint32 aIndex); |
|
1100 inline void SetBitVal(TUint32 aIndex, TBool aVal); |
|
1101 |
|
1102 void Fill(TBool aVal); |
|
1103 void Fill(TUint32 aIndexFrom, TUint32 aIndexTo, TBool aVal); |
|
1104 |
|
1105 void Invert(); |
|
1106 |
|
1107 TBool operator==(const RBitVector& aRhs) const; |
|
1108 TBool operator!=(const RBitVector& aRhs) const; |
|
1109 |
|
1110 //-- logical operations between 2 vectors. |
|
1111 void And(const RBitVector& aRhs); |
|
1112 void Or (const RBitVector& aRhs); |
|
1113 void Xor(const RBitVector& aRhs); |
|
1114 |
|
1115 TBool Diff(const RBitVector& aRhs, TUint32& aDiffIndex) const; |
|
1116 |
|
1117 /** Bit search specifiers */ |
|
1118 enum TFindDirection |
|
1119 { |
|
1120 ELeft, ///< Search from the given position to the left (towards lower index) |
|
1121 ERight, ///< Search from the given position to the right (towards higher index) |
|
1122 ENearestL, ///< Search in both directions starting from the given position; in the case of the equal distances return the position to the left |
|
1123 ENearestR ///< Search in both directions starting from the given position; in the case of the equal distances return the position to the right |
|
1124 |
|
1125 //-- N.B the current position the search starts with isn't included to the search. |
|
1126 }; |
|
1127 |
|
1128 TBool Find(TUint32& aStartPos, TBool aBitVal, TFindDirection aDir) const; |
|
1129 |
|
1130 /** panic codes */ |
|
1131 enum TPanicCode |
|
1132 { |
|
1133 EIndexOutOfRange, ///< index out of range |
|
1134 EWrondFindDirection, ///< a value doesn't belong to TFindDirection |
|
1135 ESizeMismatch, ///< Size mismatch for binary operators |
|
1136 ENotInitialised, ///< No memory allocated for the array |
|
1137 ENotImplemented, ///< functionality isn't implemented |
|
1138 }; |
|
1139 |
|
1140 protected: |
|
1141 |
|
1142 //-- these are outlawed. Can't use them because memory allocator can leave and we don't have conthrol on it in these methods. |
|
1143 RBitVector(const RBitVector& aRhs); |
|
1144 RBitVector& operator=(const RBitVector& aRhs); |
|
1145 |
|
1146 void Panic(TPanicCode aPanicCode) const; |
|
1147 |
|
1148 inline TUint32 WordNum(TUint32 aBitPos) const; |
|
1149 inline TUint32 BitInWord(TUint32 aBitPos) const; |
|
1150 |
|
1151 private: |
|
1152 TBool FindToRight(TUint32& aStartPos, TBool aBitVal) const; |
|
1153 TBool FindToLeft (TUint32& aStartPos, TBool aBitVal) const; |
|
1154 TBool FindNearest(TUint32& aStartPos, TBool aBitVal, TBool aToLeft) const; |
|
1155 |
|
1156 inline TUint32 MaskLastWord(TUint32 aVal) const; |
|
1157 inline TBool ItrLeft(TUint32& aIdx) const; |
|
1158 inline TBool ItrRight(TUint32& aIdx) const; |
|
1159 |
|
1160 |
|
1161 protected: |
|
1162 |
|
1163 TUint32 iNumBits; ///< number of bits in the vector |
|
1164 TUint32* ipData; ///< pointer to the data |
|
1165 TUint32 iNumWords;///< number of 32-bit words that store bits |
|
1166 }; |
|
1167 |
|
1168 |
|
1169 //----------------------------------------------------------------------------- |
|
1170 |
1060 |
1171 |
1061 |
1172 #include "sl_std.inl" |
1062 #include "sl_std.inl" |
1173 #include "sl_bpb.inl" |
1063 #include "sl_bpb.inl" |
1174 #include "fat_dir_entry.inl" |
1064 #include "fat_dir_entry.inl" |