sl@0
|
1 |
// Copyright (c) 1995-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\sfsrv\cl_entry.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "cl_std.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
Default constructor.
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
EXPORT_C TVolumeInfo::TVolumeInfo()
|
sl@0
|
25 |
{
|
sl@0
|
26 |
Mem::FillZ(this, sizeof(TVolumeInfo)); //-- zero-fill itself
|
sl@0
|
27 |
new(&iName)TBufC<KMaxFileName>; //-- initialise broken descriptor
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
EXPORT_C TBool TEntry::IsReadOnly() const
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
Tests whether the file or directory is read-only.
|
sl@0
|
36 |
|
sl@0
|
37 |
@return ETrue if entry is read-only, EFalse if not.
|
sl@0
|
38 |
|
sl@0
|
39 |
@see KEntryAttReadOnly
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
{
|
sl@0
|
42 |
return(iAtt&KEntryAttReadOnly);
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
|
sl@0
|
47 |
|
sl@0
|
48 |
EXPORT_C TBool TEntry::IsHidden() const
|
sl@0
|
49 |
/**
|
sl@0
|
50 |
Tests whether the file or directory is hidden.
|
sl@0
|
51 |
|
sl@0
|
52 |
@return ETrue if entry is hidden, EFalse if not.
|
sl@0
|
53 |
|
sl@0
|
54 |
@see KEntryAttHidden
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
{
|
sl@0
|
57 |
|
sl@0
|
58 |
return(iAtt&KEntryAttHidden);
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
|
sl@0
|
64 |
EXPORT_C TBool TEntry::IsSystem() const
|
sl@0
|
65 |
/**
|
sl@0
|
66 |
Tests whether the file or directory has the system attribute set.
|
sl@0
|
67 |
|
sl@0
|
68 |
@return ETrue if entry is a system entry, EFalse if not.
|
sl@0
|
69 |
|
sl@0
|
70 |
@see KEntryAttSystem
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
{
|
sl@0
|
73 |
|
sl@0
|
74 |
return(iAtt&KEntryAttSystem);
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
EXPORT_C TBool TEntry::IsDir() const
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
Tests whether the entry is a directory.
|
sl@0
|
83 |
|
sl@0
|
84 |
@return ETrue if entry indicates a directory, EFalse if not.
|
sl@0
|
85 |
|
sl@0
|
86 |
@see KEntryAttDir
|
sl@0
|
87 |
*/
|
sl@0
|
88 |
{
|
sl@0
|
89 |
|
sl@0
|
90 |
return(iAtt&KEntryAttDir);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
|
sl@0
|
94 |
|
sl@0
|
95 |
|
sl@0
|
96 |
EXPORT_C TBool TEntry::IsArchive() const
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
Tests whether the file is an archive file.
|
sl@0
|
99 |
|
sl@0
|
100 |
@return ETrue if file is archive, EFalse if not.
|
sl@0
|
101 |
|
sl@0
|
102 |
@see KEntryAttArchive
|
sl@0
|
103 |
*/
|
sl@0
|
104 |
{
|
sl@0
|
105 |
|
sl@0
|
106 |
return(iAtt&KEntryAttArchive);
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
EXPORT_C TEntryArray::TEntryArray()
|
sl@0
|
113 |
: iCount(0)
|
sl@0
|
114 |
/**
|
sl@0
|
115 |
Default constructor.
|
sl@0
|
116 |
|
sl@0
|
117 |
Initialises its count of contained TEntry objects to zero.
|
sl@0
|
118 |
*/
|
sl@0
|
119 |
{}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
|
sl@0
|
123 |
|
sl@0
|
124 |
EXPORT_C TInt TEntryArray::Count() const
|
sl@0
|
125 |
/**
|
sl@0
|
126 |
Gets the number of entries in the array.
|
sl@0
|
127 |
|
sl@0
|
128 |
@return The number of entries in the array.
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
{
|
sl@0
|
131 |
|
sl@0
|
132 |
if (iCount==KCountNeeded)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
const TEntry* pE=(const TEntry*)iBuf.Ptr();
|
sl@0
|
135 |
const TEntry* pEnd=PtrAdd(pE,iBuf.Length());
|
sl@0
|
136 |
TInt c=0;
|
sl@0
|
137 |
while (pE<pEnd)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
c++;
|
sl@0
|
140 |
pE=PtrAdd(pE,EntrySize(*pE, ETrue));
|
sl@0
|
141 |
}
|
sl@0
|
142 |
TEntryArray& me=(TEntryArray& )(*this);
|
sl@0
|
143 |
me.iCount=c;
|
sl@0
|
144 |
me.iIndex=0;
|
sl@0
|
145 |
me.iPos=(const TEntry*)iBuf.Ptr();
|
sl@0
|
146 |
}
|
sl@0
|
147 |
return(iCount);
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
|
sl@0
|
151 |
|
sl@0
|
152 |
|
sl@0
|
153 |
EXPORT_C const TEntry& TEntryArray::operator[](TInt anIndex) const
|
sl@0
|
154 |
/**
|
sl@0
|
155 |
Gets the directory entry at the specified index.
|
sl@0
|
156 |
|
sl@0
|
157 |
@param anIndex Index of the entry within the array.
|
sl@0
|
158 |
This value is relative to zero.
|
sl@0
|
159 |
|
sl@0
|
160 |
@return On return contains the entry at the specified index.
|
sl@0
|
161 |
|
sl@0
|
162 |
@panic FSCLIENT 22 if anIndex is greater than or equal to the number
|
sl@0
|
163 |
of elements in the array.
|
sl@0
|
164 |
*/
|
sl@0
|
165 |
{
|
sl@0
|
166 |
|
sl@0
|
167 |
__ASSERT_ALWAYS(anIndex<Count(),Panic(EEntryArrayBadIndex));
|
sl@0
|
168 |
const TEntry* pE=iPos;
|
sl@0
|
169 |
TInt ix=iIndex;
|
sl@0
|
170 |
if (anIndex<ix)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
ix=0;
|
sl@0
|
173 |
pE=(const TEntry*)iBuf.Ptr();
|
sl@0
|
174 |
}
|
sl@0
|
175 |
while (ix<anIndex)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
pE=PtrAdd(pE,EntrySize(*pE, ETrue));
|
sl@0
|
178 |
ix++;
|
sl@0
|
179 |
}
|
sl@0
|
180 |
TEntryArray& me=(TEntryArray& )(*this);
|
sl@0
|
181 |
me.iIndex=ix;
|
sl@0
|
182 |
me.iPos=pE;
|
sl@0
|
183 |
return(*pE);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
|
sl@0
|
187 |
|
sl@0
|
188 |
|
sl@0
|
189 |
EXPORT_C TEntry::TEntry()
|
sl@0
|
190 |
/**
|
sl@0
|
191 |
Default constructor.
|
sl@0
|
192 |
*/
|
sl@0
|
193 |
: iSizeHigh(0),
|
sl@0
|
194 |
iReserved(0)
|
sl@0
|
195 |
{}
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
|
sl@0
|
199 |
|
sl@0
|
200 |
EXPORT_C TEntry::TEntry(const TEntry& aEntry)
|
sl@0
|
201 |
/**
|
sl@0
|
202 |
Copy constructor.
|
sl@0
|
203 |
|
sl@0
|
204 |
@param aEntry The TEntry object to be copied.
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
{
|
sl@0
|
207 |
Copy(aEntry);
|
sl@0
|
208 |
Unpack(); // Check that unpacking is safe here - we need to verify that wherever
|
sl@0
|
209 |
// the entry is copied back into a TEntryArray that the iSizeHigh and
|
sl@0
|
210 |
// iReserved members are re-packaged and the attribute set accordingly.
|
sl@0
|
211 |
// (for example, CDir::Sort might do this, but I haven't checked - I know
|
sl@0
|
212 |
// this uses the assignment operator, which is why that doesn't unpack...)
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
|
sl@0
|
216 |
|
sl@0
|
217 |
|
sl@0
|
218 |
EXPORT_C TEntry& TEntry::operator=(const TEntry& aEntry)
|
sl@0
|
219 |
/**
|
sl@0
|
220 |
Assignment operator.
|
sl@0
|
221 |
|
sl@0
|
222 |
@param aEntry The TEntry object to be copied to this TEntry object.
|
sl@0
|
223 |
|
sl@0
|
224 |
@return A reference to this TEntry object.
|
sl@0
|
225 |
*/
|
sl@0
|
226 |
{
|
sl@0
|
227 |
if(this!=&aEntry)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
Copy(aEntry);
|
sl@0
|
230 |
Unpack();
|
sl@0
|
231 |
}
|
sl@0
|
232 |
return(*this);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
/**
|
sl@0
|
236 |
@internalTechnology
|
sl@0
|
237 |
@prototype
|
sl@0
|
238 |
*/
|
sl@0
|
239 |
inline void TEntry::Unpack()
|
sl@0
|
240 |
{
|
sl@0
|
241 |
if(iAtt & KEntryAttPacked)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
/**
|
sl@0
|
244 |
* This entry is still in a packed form, so unpack it now by copying high length
|
sl@0
|
245 |
* and reserved bytes from the packed source to the to the unpacked target entry
|
sl@0
|
246 |
*/
|
sl@0
|
247 |
TUint32* pSizeHighSrc = PtrAdd((TUint32*)this, EntrySize(*this, EFalse));
|
sl@0
|
248 |
|
sl@0
|
249 |
iSizeHigh = *pSizeHighSrc++; // Copy iSizeHigh
|
sl@0
|
250 |
iReserved = *pSizeHighSrc; // Copy iReserved
|
sl@0
|
251 |
|
sl@0
|
252 |
iAtt &= ~KEntryAttPacked;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
}
|
sl@0
|
255 |
|
sl@0
|
256 |
/**
|
sl@0
|
257 |
@internalTechnology
|
sl@0
|
258 |
@prototype
|
sl@0
|
259 |
*/
|
sl@0
|
260 |
inline void TEntry::Copy(const TEntry& aEntry)
|
sl@0
|
261 |
{
|
sl@0
|
262 |
Mem::Copy(this,&aEntry,EntrySize(aEntry, ETrue));
|
sl@0
|
263 |
if(!(iAtt & KEntryAttPacked))
|
sl@0
|
264 |
{
|
sl@0
|
265 |
iSizeHigh = aEntry.iSizeHigh;
|
sl@0
|
266 |
iReserved = aEntry.iReserved;
|
sl@0
|
267 |
}
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
|
sl@0
|
271 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
272 |
/**
|
sl@0
|
273 |
@internalTechnology
|
sl@0
|
274 |
@prototype
|
sl@0
|
275 |
*/
|
sl@0
|
276 |
#else
|
sl@0
|
277 |
/**
|
sl@0
|
278 |
Returns the file size in 64 bits.
|
sl@0
|
279 |
|
sl@0
|
280 |
This can be used to find the size of a file whose size is more than 2 GB - 1.
|
sl@0
|
281 |
|
sl@0
|
282 |
@return The file size in 64 bits
|
sl@0
|
283 |
|
sl@0
|
284 |
@publishedAll
|
sl@0
|
285 |
@prototype
|
sl@0
|
286 |
|
sl@0
|
287 |
@see TEntry::iSize
|
sl@0
|
288 |
*/
|
sl@0
|
289 |
#endif
|
sl@0
|
290 |
EXPORT_C TInt64 TEntry::FileSize() const
|
sl@0
|
291 |
{
|
sl@0
|
292 |
#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
293 |
Panic(ENotImplemented);
|
sl@0
|
294 |
return (KErrNotSupported); // To suppress warning!
|
sl@0
|
295 |
#else
|
sl@0
|
296 |
if(iAtt & KEntryAttPacked)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
/**
|
sl@0
|
299 |
* This entry is still in a packed form, so unpack it now by copying high length
|
sl@0
|
300 |
* and reserved bytes from the packed source to the to the unpacked target entry
|
sl@0
|
301 |
*/
|
sl@0
|
302 |
TUint32* pSizeHighSrc = PtrAdd((TUint32*)this, Align4(EntrySize(*this, EFalse)));
|
sl@0
|
303 |
return MAKE_TINT64(*pSizeHighSrc, iSize);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
return MAKE_TINT64(iSizeHigh, iSize);
|
sl@0
|
307 |
#endif
|
sl@0
|
308 |
}
|