1 s32file.h |
1 // Copyright (c) 1998-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 "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #if !defined(__S32FILE_H__) |
|
17 #define __S32FILE_H__ |
|
18 #if !defined(__F32FILE_H__) |
|
19 #include <f32file.h> |
|
20 #endif |
|
21 #if !defined(__S32STOR_H__) |
|
22 #include <s32stor.h> |
|
23 #endif |
|
24 |
|
25 #ifndef DEFAULT_FILE_BUF_SIZE |
|
26 #define DEFAULT_FILE_BUF_SIZE 4096 |
|
27 #else |
|
28 #if DEFAULT_FILE_BUF_SIZE < 1536 |
|
29 #error "DEFAULT_FILE_BUF_SIZE macro value can't be less than 1536" |
|
30 #endif |
|
31 #endif |
|
32 /** |
|
33 The default size of the file buffer. |
|
34 @internalComponent |
|
35 */ |
|
36 const TInt KDefaultFileBufSize=DEFAULT_FILE_BUF_SIZE; |
|
37 |
|
38 template <class T> |
|
39 class TCapture; |
|
40 class RPermanentFileStoreIter; |
|
41 |
|
42 /** A stream buffer hosted by a file. |
|
43 * @publishedAll |
|
44 * @released |
|
45 |
|
46 Instances of this class are used by file based persistent stores, i.e. CFileStore |
|
47 type objects. An RFileBuf object is associated with a file and the file is |
|
48 said to be attached to the stream buffer. |
|
49 |
|
50 An RFileBuf object is also used by RFileReadStream and RFileWriteStream objects |
|
51 to provide buffered file I/O. |
|
52 |
|
53 The stream buffer has intermediate buffering capabilities. |
|
54 |
|
55 When used as the basis for a file store, it hosts multiple streams through |
|
56 the TStreamExchange and RShareBuf classes. |
|
57 |
|
58 Open(), Close(), Attach(), Detach(), File() and Reattach() usage patterns: |
|
59 |
|
60 Pattern 1: RFileBuf owns the file |
|
61 step 1a: Open()/Create()/Temp() is used to connect the buffer to a file |
|
62 step 1b: Use the file buffer |
|
63 step 1c: Close() releases this resource. |
|
64 |
|
65 Pattern 2: RFile is opened elsewhere and ownership is handed over to RFileBuf |
|
66 This may happen if the file is already opened by another API, or from another process for example |
|
67 step 2a: Attach() is used to hand ownership of the opened file to the buffer. After Attach() the supplied file handle is NULLed. |
|
68 step 2b: Use the file buffer |
|
69 step 2c: Close() releases the file resource. |
|
70 |
|
71 Pattern 3: RFileBuf is used transiently to manage an existing opened file: |
|
72 step 3a: Attach() is used to bind the buffer to the already open file. After Attach() the supplied file handle is NULLed. |
|
73 step 3b: Use the file buffer |
|
74 step 3c: RFileBuf::File() is used to retrieve the file handle again, then Detach() is called to disconnect the buffer from the file. |
|
75 At this point, the destruction of the file buffer will have no effect on the file. The retrieved file handle in step 3c must be used to close the file. |
|
76 |
|
77 Pattern 4: Transient direct file access to a buffered file |
|
78 step 4a: RFileBuf::File() is used to retrieve the file handle. [Optional: Detach() is used to disconnect the file buffer] |
|
79 step 4b: Use the file directly. Note that writing to the file may cause coherency problems with the RFileBuf buffer - in which case you need to Reset() the buffer as well. |
|
80 step 4c: [Optional: Reattach() is used to hand the file back to the buffer]. Use of the buffer is resumed |
|
81 |
|
82 @see CFileStore |
|
83 @see RFileReadStream |
|
84 @see RFileWriteStream */ |
|
85 class RFileBuf : public TStreamBuf |
|
86 { |
|
87 public: |
|
88 IMPORT_C RFileBuf(); |
|
89 IMPORT_C RFileBuf(TInt aSize); |
|
90 RFileBuf(TCapture<RFileBuf> aCapture); |
|
91 IMPORT_C void Reset(); |
|
92 inline void Reset(TInt aSize); |
|
93 // |
|
94 IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
95 IMPORT_C TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
96 IMPORT_C TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
97 IMPORT_C TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
98 IMPORT_C void Attach(RFile& aFile,TInt aPos=0); |
|
99 IMPORT_C void Close(); |
|
100 inline void Detach(); |
|
101 inline void Reattach(RFile& aFile); |
|
102 // |
|
103 IMPORT_C void SetSizeL(TInt aSize); |
|
104 inline RFile& File() const; |
|
105 protected: |
|
106 IMPORT_C TInt UnderflowL(TInt aMaxLength); |
|
107 IMPORT_C void OverflowL(); |
|
108 IMPORT_C void DoRelease(); |
|
109 IMPORT_C void DoSynchL(); |
|
110 IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength); |
|
111 IMPORT_C TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus); |
|
112 IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength); |
|
113 IMPORT_C TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus); |
|
114 IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset); |
|
115 // |
|
116 inline void SetBuf(TRead,TUint8* aPtr,TUint8* anEnd); |
|
117 inline void SetBuf(TWrite,TUint8* aPtr,TUint8* anEnd); |
|
118 inline void SetBuf(TArea anArea,TUint8* aPtr,TUint8* anEnd); |
|
119 private: |
|
120 TUint8* AllocL(); |
|
121 void Free(); |
|
122 // |
|
123 void SetPos(TMark aMark,TInt aPos); |
|
124 inline void SetPos(TRead,TInt aPos); |
|
125 inline void SetPos(TWrite,TInt aPos); |
|
126 inline TInt Pos(TRead) const; |
|
127 inline TInt Pos(TWrite) const; |
|
128 inline TInt MovePos(TRead,TInt anOffset); |
|
129 inline TInt MovePos(TWrite,TInt anOffset); |
|
130 TInt FileReadL(TAny* aPtr,TInt aMaxLength); |
|
131 void FileWriteL(const TAny* aPtr,TInt aLength,TInt aSeek); |
|
132 void FileWriteL(const TAny* aPtr,TInt aLength); |
|
133 TInt EndL(); |
|
134 // |
|
135 inline TInt Lag(TRead) const; |
|
136 inline TInt Lag(TWrite) const; |
|
137 TInt Mark(TMark aMark) const; |
|
138 inline TInt Mark(TRead) const; |
|
139 inline TInt Mark(TWrite) const; |
|
140 inline TUint8* Limit(TWrite) const; |
|
141 inline void SetLimit(TWrite,TUint8* aLimit); |
|
142 inline TInt Span(TWrite) const; |
|
143 inline TInt Reach(TWrite) const; |
|
144 private: |
|
145 TUint8* iBase; |
|
146 TInt iSize; |
|
147 __MUTABLE RFile iFile; |
|
148 TInt iRPos; |
|
149 TInt iWPos; |
|
150 TInt iExt; |
|
151 TUint8* iWLim; |
|
152 friend class CFileStore; |
|
153 }; |
|
154 |
|
155 /** |
|
156 * @publishedAll |
|
157 * @released |
|
158 * Supports the reading of a stream from a file. |
|
159 */ |
|
160 class RFileReadStream : public RReadStream |
|
161 { |
|
162 public: |
|
163 /** Constructs an empty read stream object. */ |
|
164 RFileReadStream() {} |
|
165 IMPORT_C RFileReadStream(RFile& aFile,TInt aPos=0); |
|
166 IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
167 IMPORT_C void Attach(RFile& aFile,TInt aPos=0); |
|
168 private: |
|
169 RFileBuf iSource; |
|
170 }; |
|
171 |
|
172 /** |
|
173 * @publishedAll |
|
174 * @released |
|
175 * Supports the writing of a stream to a file. |
|
176 */ |
|
177 class RFileWriteStream : public RWriteStream |
|
178 { |
|
179 public: |
|
180 /** Constructs an empty write stream object. */ |
|
181 RFileWriteStream() {} |
|
182 inline RFileWriteStream(const MExternalizer<TStreamRef>& anExter); |
|
183 IMPORT_C RFileWriteStream(RFile& aFile,TInt aPos=0); |
|
184 IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
185 IMPORT_C TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
186 IMPORT_C TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
187 IMPORT_C TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
188 IMPORT_C void Attach(RFile& aFile,TInt aPos=0); |
|
189 private: |
|
190 RFileBuf iSink; |
|
191 }; |
|
192 // |
|
193 class CFileStore; |
|
194 |
|
195 /** |
|
196 * @publishedAll |
|
197 * @released |
|
198 * A class containing a set of factory functions for opening an existing direct |
|
199 file store and an existing permanent file store identified using a Uidtype. |
|
200 */ |
|
201 class FileStoreFactory |
|
202 { |
|
203 public: |
|
204 IMPORT_C static CFileStore* DirectLC(RFileBuf& aBuf,const TUidType& aType); |
|
205 IMPORT_C static CFileStore* PermanentLC(RFileBuf& aBuf,const TUidType& aType); |
|
206 }; |
|
207 // |
|
208 const TInt KDirectFileStoreLayoutUidValue=268435511; |
|
209 /** The value of the KPermanentFileStoreLayoutUidValue UID. */ |
|
210 const TInt KPermanentFileStoreLayoutUidValue=268435536; |
|
211 /** The UID that identifies a file store as being a direct file store. */ |
|
212 const TUid KDirectFileStoreLayoutUid={KDirectFileStoreLayoutUidValue}; |
|
213 /** The UID that identifies a file store as being a permanent file store. */ |
|
214 const TUid KPermanentFileStoreLayoutUid={KPermanentFileStoreLayoutUidValue}; |
|
215 // |
|
216 typedef CFileStore* (*TFileStoreFactoryFunction)(RFileBuf& aBuf,const TUidType& aType); |
|
217 // |
|
218 #define KDirectFileStoreFactoryFunction (&FileStoreFactory::DirectLC) |
|
219 #define KPermanentFileStoreFactoryFunction (&FileStoreFactory::PermanentLC) |
|
220 |
|
221 /** |
|
222 * @publishedAll |
|
223 * @released |
|
224 * File based persistent store abstract base class. |
|
225 |
|
226 The class encapsulates the basic behaviour of file based stores. File based |
|
227 stores are persistent stores, i.e. they have the ability to keep the external |
|
228 representation of objects for longer than the lifetime of the applications |
|
229 which created those objects. |
|
230 |
|
231 The class forms the base for the direct file store, CDirectFileStore, and |
|
232 the permanent file store, CPermanentFileStore. In general, it is sufficient |
|
233 for pointers to file based store objects to be of type CFileStore, rather |
|
234 than of the concrete file store type. |
|
235 |
|
236 Existing file stores can be opened using the member functions OpenL(), OpenLC(), |
|
237 FromL() and FromLC(). New file stores, however, must be created using the |
|
238 appropriate member function of the concrete type. |
|
239 */ |
|
240 class CFileStore : public CPersistentStore |
|
241 { |
|
242 public: |
|
243 IMPORT_C static CFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
244 IMPORT_C static CFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
245 IMPORT_C static CFileStore* FromL(RFile& aFile); |
|
246 IMPORT_C static CFileStore* FromLC(RFile& aFile); |
|
247 // |
|
248 IMPORT_C static CFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[]); |
|
249 IMPORT_C static CFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[]); |
|
250 IMPORT_C static CFileStore* FromL(RFile& aFile,const TFileStoreFactoryFunction aFactory[]); |
|
251 IMPORT_C static CFileStore* FromLC(RFile& aFile,const TFileStoreFactoryFunction aFactory[]); |
|
252 // |
|
253 inline const TUidType& Type() const; |
|
254 IMPORT_C void SetTypeL(const TUidType& aType); |
|
255 /** Gets the UID that uniquely identifies the specific type of this file store. |
|
256 |
|
257 This function must be defined and implemented by classes derived from CFileStore. |
|
258 The direct file store, CDirectFileStore and the permanent file store, CPermanentFileStore |
|
259 both implement suitable functions. |
|
260 |
|
261 @return The UID that uniquely identifies the specific type of file store. |
|
262 @see KDirectFileStoreLayoutUid |
|
263 @see KPermanentFileStoreLayoutUid */ |
|
264 virtual TUid Layout() const=0; |
|
265 // |
|
266 inline void Reset(); |
|
267 inline void Reset(TInt aSize); |
|
268 inline void Detach(); |
|
269 inline void Reattach(RFile& aFile); |
|
270 inline RFile& File() const; |
|
271 // |
|
272 IMPORT_C void MarshalL(); |
|
273 IMPORT_C ~CFileStore(); |
|
274 protected: |
|
275 typedef CFileStore* (*TNewFunction)(RFile& aFile); |
|
276 protected: |
|
277 IMPORT_C static CFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,TFileStoreFactoryFunction aFunction); |
|
278 IMPORT_C static CFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode,TFileStoreFactoryFunction aFunction); |
|
279 IMPORT_C static CFileStore* CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); |
|
280 IMPORT_C static CFileStore* CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); |
|
281 IMPORT_C static CFileStore* ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); |
|
282 IMPORT_C static CFileStore* ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode,TNewFunction aFunction); |
|
283 IMPORT_C static CFileStore* TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode,TNewFunction aFunction); |
|
284 IMPORT_C static CFileStore* TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode,TNewFunction aFunction); |
|
285 // |
|
286 IMPORT_C static CFileStore* FromL(RFile& aFile,TFileStoreFactoryFunction aFunction); |
|
287 IMPORT_C static CFileStore* FromLC(RFile& aFile,TFileStoreFactoryFunction aFunction); |
|
288 IMPORT_C static CFileStore* NewL(RFile& aFile,TNewFunction aFunction); |
|
289 IMPORT_C static CFileStore* NewLC(RFile& aFile,TNewFunction aFunction); |
|
290 // |
|
291 IMPORT_C CFileStore(RFile& aFile); |
|
292 IMPORT_C CFileStore(RFileBuf& aBuf,const TUidType& aType); |
|
293 IMPORT_C void Destruct(); |
|
294 // |
|
295 inline TStreamExchange& Host() const; |
|
296 inline TBool IsHost(const MStreamBuf* aBuf) const; |
|
297 IMPORT_C void SynchL(); |
|
298 inline void SetSizeL(TInt aSize); |
|
299 IMPORT_C void ChangedL(); |
|
300 IMPORT_C void RefreshL(); |
|
301 // |
|
302 IMPORT_C void DoCommitL(); |
|
303 IMPORT_C void DoRevertL(); |
|
304 private: |
|
305 virtual void ExternalizeL(RWriteStream& aStream) const=0; |
|
306 virtual void InternalizeL(RReadStream& aStream)=0; |
|
307 // |
|
308 static CFileStore* DoNewL(RFile& aFile,TNewFunction aFunction); |
|
309 private: |
|
310 RFileBuf iBuf; |
|
311 TUidType iType; |
|
312 __MUTABLE TStreamExchange iHost; |
|
313 }; |
|
314 const TInt KFileStoreStartOffset=sizeof(TCheckedUid); |
|
315 #if defined(__NO_CLASS_CONSTS__) |
|
316 #define KFileStoreStart TStreamPos(KFileStoreStartOffset) |
|
317 #else |
|
318 const TStreamPos KFileStoreStart=TStreamPos(KFileStoreStartOffset); |
|
319 #endif |
|
320 |
|
321 /** |
|
322 * @publishedAll |
|
323 * @released |
|
324 * Direct file store. |
|
325 |
|
326 A direct file store implements a subset of the operations defined by the store |
|
327 abstract framework. Direct file stores allow streams to be created and objects |
|
328 externalised to them however once the streams have been committed and |
|
329 closed, they cannot subsequently be changed, i.e. streams cannot be replaced, |
|
330 deleted, extended or changed in any way. |
|
331 */ |
|
332 class CDirectFileStore : public CFileStore |
|
333 { |
|
334 public: |
|
335 inline static CDirectFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
336 inline static CDirectFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
337 inline static CDirectFileStore* CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
338 inline static CDirectFileStore* CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
339 inline static CDirectFileStore* ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
340 inline static CDirectFileStore* ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
341 inline static CDirectFileStore* TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
342 inline static CDirectFileStore* TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
343 // |
|
344 inline static CDirectFileStore* FromL(RFile& aFile); |
|
345 inline static CDirectFileStore* FromLC(RFile& aFile); |
|
346 inline static CDirectFileStore* NewL(RFile& aFile); |
|
347 inline static CDirectFileStore* NewLC(RFile& aFile); |
|
348 // |
|
349 IMPORT_C TUid Layout() const; |
|
350 // |
|
351 IMPORT_C CDirectFileStore(RFile& aFile); |
|
352 IMPORT_C CDirectFileStore(RFileBuf& aBuf,const TUidType& aType); |
|
353 protected: |
|
354 IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const; |
|
355 IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId); |
|
356 private: |
|
357 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
358 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
359 IMPORT_C void DoSetRootL(TStreamId anId); |
|
360 // |
|
361 IMPORT_C static CFileStore* DoNewL(RFile& aFile); |
|
362 }; |
|
363 // |
|
364 class CPermanentStoreCoord; |
|
365 |
|
366 /** |
|
367 * @publishedAll |
|
368 * @released |
|
369 * Permanent file store. |
|
370 |
|
371 This type of store supports full manipulation of store contents. Existing |
|
372 streams within this type of store can be changed. |
|
373 */ |
|
374 class CPermanentFileStore : public CFileStore |
|
375 { |
|
376 friend class RPermanentFileStoreIter; |
|
377 public: |
|
378 inline static CPermanentFileStore* OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
379 inline static CPermanentFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
380 inline static CPermanentFileStore* CreateL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
381 inline static CPermanentFileStore* CreateLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
382 inline static CPermanentFileStore* ReplaceL(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
383 inline static CPermanentFileStore* ReplaceLC(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
384 inline static CPermanentFileStore* TempL(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
385 inline static CPermanentFileStore* TempLC(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
386 // |
|
387 inline static CPermanentFileStore* FromL(RFile& aFile); |
|
388 inline static CPermanentFileStore* FromLC(RFile& aFile); |
|
389 inline static CPermanentFileStore* NewL(RFile& aFile); |
|
390 inline static CPermanentFileStore* NewLC(RFile& aFile); |
|
391 // |
|
392 IMPORT_C TUid Layout() const; |
|
393 // |
|
394 IMPORT_C CPermanentFileStore(RFile& aFile); |
|
395 IMPORT_C CPermanentFileStore(RFileBuf& aBuf,const TUidType& aType); |
|
396 IMPORT_C void MarshalL(); |
|
397 IMPORT_C ~CPermanentFileStore(); |
|
398 protected: |
|
399 IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const; |
|
400 IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId); |
|
401 IMPORT_C MStreamBuf* DoWriteL(TStreamId anId); |
|
402 IMPORT_C MStreamBuf* DoReplaceL(TStreamId anId); |
|
403 private: |
|
404 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
405 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
406 IMPORT_C void DoSetRootL(TStreamId anId); |
|
407 IMPORT_C TStreamId DoExtendL(); |
|
408 IMPORT_C void DoDeleteL(TStreamId anId); |
|
409 IMPORT_C void DoCommitL(); |
|
410 IMPORT_C void DoRevertL(); |
|
411 IMPORT_C MIncrementalCollector* DoReclaimL(); |
|
412 IMPORT_C MIncrementalCollector* DoCompactL(); |
|
413 // |
|
414 inline CPermanentStoreCoord& Coord() const; |
|
415 CPermanentStoreCoord& CoordL() const; |
|
416 CPermanentStoreCoord& TrimL(); |
|
417 // |
|
418 IMPORT_C static CFileStore* DoNewL(RFile& aFile); |
|
419 private: |
|
420 __MUTABLE CPermanentStoreCoord* iCoord; |
|
421 }; |
|
422 |
|
423 /** |
|
424 * @publishedAll |
|
425 * @released |
|
426 * File based dictionary store. |
|
427 |
|
428 A dictionary store is a store where a stream is accessed by UID, rather than |
|
429 directly by stream ID. A dictionary store contains streams in the usual way |
|
430 but, in addition, the root stream is a stream dictionary, i.e. a CStreamDictionary |
|
431 type. |
|
432 */ |
|
433 class CDictionaryFileStore : public CDictionaryStore |
|
434 { |
|
435 public: |
|
436 IMPORT_C static CDictionaryFileStore* SystemL(RFs& aFs); |
|
437 IMPORT_C static CDictionaryFileStore* SystemLC(RFs& aFs); |
|
438 IMPORT_C static CDictionaryFileStore* OpenL(RFs& aFs,const TDesC& aName,TUid aUid3); |
|
439 IMPORT_C static CDictionaryFileStore* OpenLC(RFs& aFs,const TDesC& aName,TUid aUid3); |
|
440 private: |
|
441 void ConstructL(RFs& aFs,const TDesC& aName,TUid aUid3); |
|
442 void CreateStoreL(RFile& aFile,const TUidType& aType); |
|
443 }; |
|
444 |
|
445 /** |
|
446 * @publishedAll |
|
447 * @released |
|
448 * Uses a file directly to implement the page pool interface MPagePool. |
|
449 |
|
450 The pages are written sequentially through the file. You should call Close() |
|
451 to release the file resource after CreateL(), OpenL(), ReplaceL() or Temp(). |
|
452 |
|
453 A file page pool uses a cache to store pages in-memory and to cache frequently |
|
454 accessed pages. You should provide a cache object (CPageCache) to the pool |
|
455 for this purpose. |
|
456 |
|
457 @see CPageCache |
|
458 @see RFile |
|
459 */ |
|
460 class RFilePagePool : public TCachePagePool |
|
461 { |
|
462 public: |
|
463 IMPORT_C RFilePagePool(); |
|
464 IMPORT_C RFilePagePool(CPageCache& aCache); |
|
465 // |
|
466 inline TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
467 inline TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
468 inline TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode); |
|
469 inline TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode); |
|
470 inline void Attach(RFile& aFile); |
|
471 IMPORT_C void Close(); |
|
472 IMPORT_C void Release(); |
|
473 IMPORT_C TInt Flush(); |
|
474 IMPORT_C void FlushL(); |
|
475 inline void Detach(); |
|
476 // |
|
477 inline RFile& File() const; |
|
478 protected: |
|
479 IMPORT_C TPageRef ExtendL(const TAny* aPage,TPageReclamation aReclamation); |
|
480 IMPORT_C void WriteL(TPageRef aRef,const TAny* aPage,TPageChange aChange); |
|
481 IMPORT_C void ReadL(TPageRef aRef,TAny* aPage); |
|
482 private: |
|
483 __MUTABLE RFile iFile; |
|
484 }; |
|
485 |
|
486 #include <s32file.inl> |
|
487 #endif |