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