2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
28 #ifndef __DIRSTREAMABLE_H__
29 #define __DIRSTREAMABLE_H__
33 #include <caf/caftypes.h>
35 namespace ContentAccess
37 /** Emulates the behavior of a CDir object with the addition of
40 Functions are not virtual and do not override the CDir
41 functions so most of the time this class will be used as if it was
42 a CDir. It is only when used explicitly as a CDirStreamable that
43 any additional functionality is invoked
48 class CDirStreamable : public CDir
51 /** Constuct an empty CDirStreamable
52 @return a CDirStreamable with no entries
54 IMPORT_C static CDirStreamable* NewL();
56 /** Construct a CDirStreamable object from the result
57 of a call to RFs::GetDir()
59 @param aDir A CDir object which has been constructed by a previous call
61 @return A new CDirStreamable object
63 IMPORT_C static CDirStreamable* NewL(CDir& aDir);
65 /** Construct a CDirStreamable object from a stream
67 @param aStream The stream to read the CDirStreamable object from
68 @return A new CDirStreamable object
70 IMPORT_C static CDirStreamable* NewL(RReadStream aStream);
73 virtual ~CDirStreamable();
76 @param aEntry The directory entry to add
78 IMPORT_C void AddL(const TEntry &aEntry);
80 /** The number of file system entries in the CDirStreamable
82 @return The number of TEntry objects in the CDirStreamable
84 IMPORT_C TInt Count() const;
86 /** Retrieve the file system entry at a particular index
90 @param aIndex The entry to retrieve
91 @return A reference to the TEntry stored by the CDirStreamable
93 IMPORT_C const TEntry& operator[](TInt aIndex) const;
95 /** Sort the entries in the specified order
96 @param aEntrySortKey A TEntryKey value used to sort the array.
97 @return KErrNone if sort was successful
99 IMPORT_C TInt Sort(TUint aEntrySortKey);
102 /** Write this CDirStreamable to a stream
103 @param aStream The stream to write to
105 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
110 void ConstructL(CDir& aDir);
112 void InternalizeL(RReadStream& aStream);