First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfsrv\cl_entry.cpp
24 EXPORT_C TVolumeInfo::TVolumeInfo()
26 Mem::FillZ(this, sizeof(TVolumeInfo)); //-- zero-fill itself
27 new(&iName)TBufC<KMaxFileName>; //-- initialise broken descriptor
33 EXPORT_C TBool TEntry::IsReadOnly() const
35 Tests whether the file or directory is read-only.
37 @return ETrue if entry is read-only, EFalse if not.
39 @see KEntryAttReadOnly
42 return(iAtt&KEntryAttReadOnly);
48 EXPORT_C TBool TEntry::IsHidden() const
50 Tests whether the file or directory is hidden.
52 @return ETrue if entry is hidden, EFalse if not.
58 return(iAtt&KEntryAttHidden);
64 EXPORT_C TBool TEntry::IsSystem() const
66 Tests whether the file or directory has the system attribute set.
68 @return ETrue if entry is a system entry, EFalse if not.
74 return(iAtt&KEntryAttSystem);
80 EXPORT_C TBool TEntry::IsDir() const
82 Tests whether the entry is a directory.
84 @return ETrue if entry indicates a directory, EFalse if not.
90 return(iAtt&KEntryAttDir);
96 EXPORT_C TBool TEntry::IsArchive() const
98 Tests whether the file is an archive file.
100 @return ETrue if file is archive, EFalse if not.
102 @see KEntryAttArchive
106 return(iAtt&KEntryAttArchive);
112 EXPORT_C TEntryArray::TEntryArray()
117 Initialises its count of contained TEntry objects to zero.
124 EXPORT_C TInt TEntryArray::Count() const
126 Gets the number of entries in the array.
128 @return The number of entries in the array.
132 if (iCount==KCountNeeded)
134 const TEntry* pE=(const TEntry*)iBuf.Ptr();
135 const TEntry* pEnd=PtrAdd(pE,iBuf.Length());
140 pE=PtrAdd(pE,EntrySize(*pE, ETrue));
142 TEntryArray& me=(TEntryArray& )(*this);
145 me.iPos=(const TEntry*)iBuf.Ptr();
153 EXPORT_C const TEntry& TEntryArray::operator[](TInt anIndex) const
155 Gets the directory entry at the specified index.
157 @param anIndex Index of the entry within the array.
158 This value is relative to zero.
160 @return On return contains the entry at the specified index.
162 @panic FSCLIENT 22 if anIndex is greater than or equal to the number
163 of elements in the array.
167 __ASSERT_ALWAYS(anIndex<Count(),Panic(EEntryArrayBadIndex));
168 const TEntry* pE=iPos;
173 pE=(const TEntry*)iBuf.Ptr();
177 pE=PtrAdd(pE,EntrySize(*pE, ETrue));
180 TEntryArray& me=(TEntryArray& )(*this);
189 EXPORT_C TEntry::TEntry()
200 EXPORT_C TEntry::TEntry(const TEntry& aEntry)
204 @param aEntry The TEntry object to be copied.
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...)
218 EXPORT_C TEntry& TEntry::operator=(const TEntry& aEntry)
222 @param aEntry The TEntry object to be copied to this TEntry object.
224 @return A reference to this TEntry object.
239 inline void TEntry::Unpack()
241 if(iAtt & KEntryAttPacked)
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
247 TUint32* pSizeHighSrc = PtrAdd((TUint32*)this, EntrySize(*this, EFalse));
249 iSizeHigh = *pSizeHighSrc++; // Copy iSizeHigh
250 iReserved = *pSizeHighSrc; // Copy iReserved
252 iAtt &= ~KEntryAttPacked;
260 inline void TEntry::Copy(const TEntry& aEntry)
262 Mem::Copy(this,&aEntry,EntrySize(aEntry, ETrue));
263 if(!(iAtt & KEntryAttPacked))
265 iSizeHigh = aEntry.iSizeHigh;
266 iReserved = aEntry.iReserved;
271 #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
278 Returns the file size in 64 bits.
280 This can be used to find the size of a file whose size is more than 2 GB - 1.
282 @return The file size in 64 bits
290 EXPORT_C TInt64 TEntry::FileSize() const
292 #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
293 Panic(ENotImplemented);
294 return (KErrNotSupported); // To suppress warning!
296 if(iAtt & KEntryAttPacked)
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
302 TUint32* pSizeHighSrc = PtrAdd((TUint32*)this, Align4(EntrySize(*this, EFalse)));
303 return MAKE_TINT64(*pSizeHighSrc, iSize);
306 return MAKE_TINT64(iSizeHigh, iSize);