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