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