|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // f32\sfat\inc\fat_dir_entry.inl |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
25 //!! |
|
26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it |
|
27 //!! |
|
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
30 |
|
31 |
|
32 #if !defined(FAT_DIR_ENTRY_INL) |
|
33 #define FAT_DIR_ENTRY_INL |
|
34 |
|
35 //------------------------------------------------------------------------------------------------------------------- |
|
36 |
|
37 |
|
38 /** |
|
39 Defined cast of Fat directory entry data read to structure allowing access to data |
|
40 */ |
|
41 #define pDir ((SFatDirEntry*)&iData[0]) |
|
42 |
|
43 |
|
44 inline TFatDirEntry::TFatDirEntry() |
|
45 { |
|
46 InitZ(); |
|
47 } |
|
48 |
|
49 /** zero-fill the entry contents */ |
|
50 inline void TFatDirEntry::InitZ() |
|
51 { |
|
52 Mem::FillZ(iData, KSizeOfFatDirEntry); |
|
53 } |
|
54 |
|
55 /** |
|
56 Return the Dos name of a directory entry |
|
57 |
|
58 @return A descriptor containing the Dos name of a directory entry |
|
59 */ |
|
60 inline const TPtrC8 TFatDirEntry::Name() const |
|
61 {return TPtrC8((TUint8*)&(pDir->iName),KFatDirNameSize);} |
|
62 /** |
|
63 @return The attributes for the Directory entry |
|
64 */ |
|
65 inline TInt TFatDirEntry::Attributes() const |
|
66 {return pDir->iAttributes;} |
|
67 /** |
|
68 @param aOffset This offset will be subtracted from the returned time. |
|
69 @return Time of file modification |
|
70 */ |
|
71 inline TTime TFatDirEntry::Time(TTimeIntervalSeconds aOffset) const |
|
72 { |
|
73 TTime time=DosTimeToTTime(pDir->iTime,pDir->iDate); |
|
74 return time-=aOffset; |
|
75 } |
|
76 /** |
|
77 @return The Start cluster for the file or directory for this entry |
|
78 */ |
|
79 inline TInt TFatDirEntry::StartCluster() const |
|
80 { |
|
81 const TUint16 KStClustMaskHi = 0x0FFF; |
|
82 return ((pDir->iStartClusterHi & KStClustMaskHi) << 16) | pDir->iStartClusterLo; |
|
83 } |
|
84 |
|
85 /** |
|
86 @return The size of file or directory for this entry |
|
87 */ |
|
88 inline TUint32 TFatDirEntry::Size() const |
|
89 {return pDir->iSize;} |
|
90 /** |
|
91 @return True if the entry is erased |
|
92 */ |
|
93 inline TBool TFatDirEntry::IsErased() const |
|
94 {return (TBool)(iData[0]==KEntryErasedMarker);} |
|
95 /** |
|
96 @return True if the entry refers to the current directory |
|
97 */ |
|
98 inline TBool TFatDirEntry::IsCurrentDirectory() const |
|
99 {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KBlankSpace);} |
|
100 /** |
|
101 @return True if the Entry refers to the parent directory |
|
102 */ |
|
103 inline TBool TFatDirEntry::IsParentDirectory() const |
|
104 {return (TBool)(iData[0]==KDotEntryByte && iData[1]==KDotEntryByte);} |
|
105 /** |
|
106 @return True if end of directory |
|
107 */ |
|
108 inline TBool TFatDirEntry::IsEndOfDirectory() const |
|
109 {return (TBool)(iData[0]==0x00);} |
|
110 /** |
|
111 Set the Dos name of a directory entry |
|
112 |
|
113 @param aDes A descriptor containg the name |
|
114 */ |
|
115 inline void TFatDirEntry::SetName(const TDesC8& aDes) |
|
116 { |
|
117 __ASSERT_DEBUG(aDes.Length()<=KFatDirNameSize,Fault(EFatBadDirEntryParameter)); |
|
118 TPtr8 name(pDir->iName,KFatDirNameSize); |
|
119 name=aDes; |
|
120 } |
|
121 /** |
|
122 Set the file or directory attributes for this entry |
|
123 |
|
124 @param anAtts The file or directory attributes |
|
125 */ |
|
126 inline void TFatDirEntry::SetAttributes(TInt anAtts) |
|
127 { |
|
128 __ASSERT_DEBUG(!(anAtts&~KMaxTUint8),Fault(EFatBadDirEntryParameter)); |
|
129 pDir->iAttributes=(TUint8)anAtts; |
|
130 } |
|
131 /** |
|
132 Set the modification time and date of the directory entry |
|
133 |
|
134 @param aTime Modification time of the file or directory |
|
135 @aOffset aOffset This offset will be added to the time. |
|
136 */ |
|
137 inline void TFatDirEntry::SetTime(TTime aTime, TTimeIntervalSeconds aOffset) |
|
138 { |
|
139 aTime+=aOffset; |
|
140 pDir->iTime=(TUint16)DosTimeFromTTime(aTime); |
|
141 pDir->iDate=(TUint16)DosDateFromTTime(aTime); |
|
142 } |
|
143 |
|
144 inline void TFatDirEntry::SetCreateTime(TTime aTime, TTimeIntervalSeconds aOffset) |
|
145 { |
|
146 aTime+=aOffset; |
|
147 pDir->iTimeC=(TUint16)DosTimeFromTTime(aTime); |
|
148 pDir->iDateC=(TUint16)DosDateFromTTime(aTime); |
|
149 } |
|
150 |
|
151 /** |
|
152 Set the start cluster number of the file or directory refered to by the entry |
|
153 |
|
154 @param aStartCluster The start cluster number |
|
155 */ |
|
156 inline void TFatDirEntry::SetStartCluster(TInt aStartCluster) |
|
157 { |
|
158 pDir->iStartClusterLo=(TUint16)(aStartCluster); |
|
159 pDir->iStartClusterHi=(TUint16)(aStartCluster >> 16); |
|
160 } |
|
161 /** |
|
162 Set the size of the file or directory refered to by the entry |
|
163 |
|
164 @param aFileSize Size of the file |
|
165 */ |
|
166 inline void TFatDirEntry::SetSize(TUint32 aFileSize) |
|
167 {pDir->iSize=aFileSize;} |
|
168 /** |
|
169 Set the directory entry as erased |
|
170 */ |
|
171 inline void TFatDirEntry::SetErased() |
|
172 {iData[0]=KEntryErasedMarker;} |
|
173 /** |
|
174 Set the current entry to refer to the current directory |
|
175 */ |
|
176 inline void TFatDirEntry::SetCurrentDirectory() |
|
177 { |
|
178 iData[0]='.'; |
|
179 Mem::Fill(&iData[1],KFatDirNameSize-1,' '); |
|
180 } |
|
181 /** |
|
182 Set the current entry to refer to the parent directory |
|
183 */ |
|
184 inline void TFatDirEntry::SetParentDirectory() |
|
185 { |
|
186 iData[0]='.';iData[1]='.'; |
|
187 Mem::Fill(&iData[2],KFatDirNameSize-2,' '); |
|
188 } |
|
189 /** |
|
190 Set the current entry to be the end of directory marker |
|
191 */ |
|
192 inline void TFatDirEntry::SetEndOfDirectory() |
|
193 {Mem::FillZ(&iData[0],KFatDirNameSize);} |
|
194 |
|
195 /** |
|
196 Get VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries |
|
197 Uses 1 byte from "Last Access Date" field, offset 19. Hack. |
|
198 */ |
|
199 TUint TFatDirEntry::RuggedFatEntryId() const |
|
200 { |
|
201 return pDir->iReserved2; |
|
202 } |
|
203 |
|
204 /** |
|
205 Set VFAT entry ID. Uset by Rugged FAT and Scan Drive to fix broken entries |
|
206 Uses 1 byte from "Last Access Date" field, offset 19. Hack. |
|
207 */ |
|
208 void TFatDirEntry::SetRuggedFatEntryId(TUint16 aId) |
|
209 { |
|
210 pDir->iReserved2 = aId; |
|
211 } |
|
212 |
|
213 |
|
214 /** |
|
215 @return True if the entry is the start of a long name set of entries |
|
216 */ |
|
217 inline TBool TFatDirEntry::IsLongNameStart() const |
|
218 {return (TBool)((iData[0]&0x40) != 0);} |
|
219 /** |
|
220 @return True is the Entry is a VFat entry |
|
221 */ |
|
222 inline TBool TFatDirEntry::IsVFatEntry() const |
|
223 {return (TBool)(Attributes()==KVFatEntryAttribute && IsEndOfDirectory()==EFalse);} |
|
224 /** |
|
225 @return The number of following VFat entries |
|
226 */ |
|
227 inline TInt TFatDirEntry::NumFollowing() const |
|
228 {return (iData[0]&0x3F);} |
|
229 |
|
230 |
|
231 inline TUint8 TFatDirEntry::CheckSum() const |
|
232 { |
|
233 ASSERT(IsVFatEntry()); |
|
234 return iData[13]; |
|
235 } |
|
236 |
|
237 |
|
238 |
|
239 /** |
|
240 @return ETrue if the Directory entry contains garbage data |
|
241 */ |
|
242 inline TBool TFatDirEntry::IsGarbage() const |
|
243 { |
|
244 return (iData[0]==0xFF); |
|
245 } |
|
246 |
|
247 |
|
248 |
|
249 #endif //FAT_DIR_ENTRY_INL |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |