51 inline const TPtrC8 TFatDirEntry::Name() const |
51 inline const TPtrC8 TFatDirEntry::Name() const |
52 {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);} |
52 {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);} |
53 /** |
53 /** |
54 @return The attributes for the Directory entry |
54 @return The attributes for the Directory entry |
55 */ |
55 */ |
56 inline TInt TFatDirEntry::Attributes() const |
56 inline TUint TFatDirEntry::Attributes() const |
57 {return pDir->iAttributes;} |
57 {return pDir->iAttributes;} |
58 /** |
58 /** |
59 @param aOffset This offset will be subtracted from the returned time. |
59 @param aOffset This offset will be subtracted from the returned time. |
60 @return Time of file modification |
60 @return Time of file modification |
61 */ |
61 */ |
65 return time-=aOffset; |
65 return time-=aOffset; |
66 } |
66 } |
67 /** |
67 /** |
68 @return The Start cluster for the file or directory for this entry |
68 @return The Start cluster for the file or directory for this entry |
69 */ |
69 */ |
70 inline TInt TFatDirEntry::StartCluster() const |
70 inline TUint32 TFatDirEntry::StartCluster() const |
71 { |
71 { |
72 const TUint16 KStClustMaskHi = 0x0FFF; |
72 const TUint16 KStClustMaskHi = 0x0FFF; |
73 return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo; |
73 return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo; |
74 } |
74 } |
75 |
75 |
76 /** |
76 /** |
77 @return The size of file or directory for this entry |
77 @return The size of file or directory for this entry |
78 */ |
78 */ |
79 inline TUint32 TFatDirEntry::Size() const |
79 inline TUint32 TFatDirEntry::Size() const |
80 {return pDir->iSize;} |
80 { |
|
81 return pDir->iSize; |
|
82 } |
|
83 |
81 /** |
84 /** |
82 @return True if the entry is erased |
85 @return True if the entry is erased |
83 */ |
86 */ |
84 inline TBool TFatDirEntry::IsErased() const |
87 inline TBool TFatDirEntry::IsErased() const |
85 {return (TBool)(iData[0]==KEntryErasedMarker);} |
88 {return (TBool)(iData[0]==KEntryErasedMarker);} |
142 /** |
145 /** |
143 Set the start cluster number of the file or directory refered to by the entry |
146 Set the start cluster number of the file or directory refered to by the entry |
144 |
147 |
145 @param aStartCluster The start cluster number |
148 @param aStartCluster The start cluster number |
146 */ |
149 */ |
147 inline void TFatDirEntry::SetStartCluster(TInt aStartCluster) |
150 inline void TFatDirEntry::SetStartCluster(TUint32 aStartCluster) |
148 { |
151 { |
149 pDir->iStartClusterLo=(TUint16)(aStartCluster); |
152 pDir->iStartClusterLo=(TUint16)(aStartCluster); |
150 pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16); |
153 pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16); |
151 } |
154 } |
152 /** |
155 /** |
153 Set the size of the file or directory refered to by the entry |
156 Set the size of the file or directory refered to by the entry |
154 |
157 |
155 @param aFileSize Size of the file |
158 @param aFileSize Size of the file |
156 */ |
159 */ |
157 inline void TFatDirEntry::SetSize(TUint32 aFileSize) |
160 inline void TFatDirEntry::SetSize(TUint32 aFileSize) |
158 {pDir->iSize=aFileSize;} |
161 { |
159 /** |
162 pDir->iSize=aFileSize; |
160 Set the directory entry as erased |
163 } |
161 */ |
164 |
|
165 /** Set the directory entry as erased */ |
162 inline void TFatDirEntry::SetErased() |
166 inline void TFatDirEntry::SetErased() |
163 {iData[0]=KEntryErasedMarker;} |
167 { |
164 /** |
168 iData[0]=KEntryErasedMarker; |
165 Set the current entry to refer to the current directory |
169 } |
166 */ |
170 |
|
171 /** Set the current entry to refer to the current directory */ |
167 inline void TFatDirEntry::SetCurrentDirectory() |
172 inline void TFatDirEntry::SetCurrentDirectory() |
168 { |
173 { |
169 iData[0]='.'; |
174 iData[0]='.'; |
170 Mem::Fill(&iData[1],KFatDirNameSize-1,' '); |
175 Mem::Fill(&iData[1],KFatDirNameSize-1,' '); |
171 } |
176 } |
172 /** |
177 |
173 Set the current entry to refer to the parent directory |
178 /** Set the current entry to refer to the parent directory */ |
174 */ |
|
175 inline void TFatDirEntry::SetParentDirectory() |
179 inline void TFatDirEntry::SetParentDirectory() |
176 { |
180 { |
177 iData[0]='.';iData[1]='.'; |
181 iData[0]='.';iData[1]='.'; |
178 Mem::Fill(&iData[2],KFatDirNameSize-2,' '); |
182 Mem::Fill(&iData[2],KFatDirNameSize-2,' '); |
179 } |
183 } |
180 /** |
184 |
181 Set the current entry to be the end of directory marker |
185 /** Set the current entry to be the end of directory marker */ |
182 */ |
|
183 inline void TFatDirEntry::SetEndOfDirectory() |
186 inline void TFatDirEntry::SetEndOfDirectory() |
184 {Mem::FillZ(&iData[0],KFatDirNameSize);} |
187 { |
|
188 Mem::FillZ(&iData[0],KFatDirNameSize); |
|
189 } |
185 |
190 |
186 /** |
191 /** |
187 Get VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries |
192 Get VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries |
188 Uses 1 byte from "Last Access Date" field, offset 19. Hack. |
193 Uses 1 byte from "Last Access Date" field, offset 19. Hack. |
189 */ |
194 */ |
190 TUint TFatDirEntry::RuggedFatEntryId() const |
195 TUint16 TFatDirEntry::RuggedFatEntryId() const |
191 { |
196 { |
192 return pDir->iReserved2; |
197 return pDir->iReserved2; |
193 } |
198 } |
194 |
199 |
195 /** |
200 /** |
200 { |
205 { |
201 pDir->iReserved2 = aId; |
206 pDir->iReserved2 = aId; |
202 } |
207 } |
203 |
208 |
204 |
209 |
205 /** |
210 /** @return True if the entry is the start of a long name set of entries */ |
206 @return True if the entry is the start of a long name set of entries |
|
207 */ |
|
208 inline TBool TFatDirEntry::IsLongNameStart() const |
211 inline TBool TFatDirEntry::IsLongNameStart() const |
209 {return (TBool)((iData[0]&0x40) != 0);} |
212 { |
210 /** |
213 return (iData[0] & 0x40); |
211 @return True is the Entry is a VFat entry |
214 } |
212 */ |
215 |
|
216 /** @return True is the Entry is a VFat entry */ |
213 inline TBool TFatDirEntry::IsVFatEntry() const |
217 inline TBool TFatDirEntry::IsVFatEntry() const |
214 {return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);} |
218 { |
215 /** |
219 return (Attributes()==KVFatEntryAttribute && IsEndOfDirectory() == EFalse); |
216 @return The number of following VFat entries |
220 } |
217 */ |
221 |
|
222 /** @return The number of following VFat entries */ |
218 inline TInt TFatDirEntry::NumFollowing() const |
223 inline TInt TFatDirEntry::NumFollowing() const |
219 {return (iData[0]&0x3F);} |
224 { |
|
225 return (iData[0]&0x3F); |
|
226 } |
220 |
227 |
221 |
228 |
222 inline TUint8 TFatDirEntry::CheckSum() const |
229 inline TUint8 TFatDirEntry::CheckSum() const |
223 { |
230 { |
224 ASSERT(IsVFatEntry()); |
231 ASSERT(IsVFatEntry()); |
225 return iData[13]; |
232 return iData[13]; |
226 } |
233 } |
227 |
234 |
228 |
235 |
229 |
|
230 /** |
236 /** |
231 @return ETrue if the Directory entry contains garbage data |
237 @return ETrue if the Directory entry contains garbage data |
232 */ |
238 */ |
233 inline TBool TFatDirEntry::IsGarbage() const |
239 inline TBool TFatDirEntry::IsGarbage() const |
234 { |
240 { |
235 return (iData[0]==0xFF); |
241 return (iData[0]==0xFF); |
236 } |
242 } |
237 |
243 |
238 |
244 |
239 |
245 |
|
246 //----------------------------------------------------------------------------- |
|
247 /** |
|
248 Checks if the entry has the same "modification time" as given (with 2 seconds granularity precision, see FAT specs). |
|
249 |
|
250 @param aTime time to check |
|
251 @param aOffset time offset |
|
252 |
|
253 @return ETrue if the given time+offset is the same (with 2 second granularity) as the one set in the entry. |
|
254 */ |
|
255 inline TBool TFatDirEntry::IsTimeTheSame(TTime aTime, TTimeIntervalSeconds aOffset) const |
|
256 { |
|
257 aTime+=aOffset; |
|
258 |
|
259 const TUint16 time = (TUint16)DosTimeFromTTime(aTime); |
|
260 if(time != pDir->iTime) |
|
261 return EFalse; |
|
262 |
|
263 const TUint16 date = (TUint16)DosDateFromTTime(aTime); |
|
264 return (date == pDir->iDate); |
|
265 } |
|
266 |
|
267 |
240 #endif //FAT_DIR_ENTRY_INL |
268 #endif //FAT_DIR_ENTRY_INL |
241 |
269 |
242 |
270 |
243 |
271 |
244 |
272 |