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