os/security/securityanddataprivacytools/securitytools/certapp/store--/s32file.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
#ifndef __S32FILE_H__
sl@0
     2
#define __S32FILE_H__/*
sl@0
     3
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     4
* All rights reserved.
sl@0
     5
* This component and the accompanying materials are made available
sl@0
     6
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     7
* which accompanies this distribution, and is available
sl@0
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     9
*
sl@0
    10
* Initial Contributors:
sl@0
    11
* Nokia Corporation - initial contribution.
sl@0
    12
*
sl@0
    13
* Contributors:
sl@0
    14
*
sl@0
    15
* Description: 
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
#include <e32base.h>
sl@0
    21
#include <f32file.h>
sl@0
    22
#include <s32strm.h>
sl@0
    23
#include <fstream>
sl@0
    24
#include <string>
sl@0
    25
#include <memory>
sl@0
    26
#include <map>
sl@0
    27
sl@0
    28
/**
sl@0
    29
 * @file
sl@0
    30
 * @internalComponent
sl@0
    31
 */
sl@0
    32
sl@0
    33
#define KPermanentFileStoreLayoutUid TUid::Uid(268435536)
sl@0
    34
typedef TUint32 TStreamId;
sl@0
    35
/** The value of the null stream ID. */
sl@0
    36
const TUint32 KNullStreamIdValue=0;
sl@0
    37
const TUint32 KMaxStreamIdValue=0xfffffff;
sl@0
    38
const TUint32 KMaskStreamIdValue=0xfffffff;
sl@0
    39
const TInt KShiftStreamIdValue=28;
sl@0
    40
sl@0
    41
namespace store_private
sl@0
    42
{
sl@0
    43
};
sl@0
    44
sl@0
    45
sl@0
    46
sl@0
    47
sl@0
    48
class CStreamStore
sl@0
    49
	{
sl@0
    50
public:
sl@0
    51
	virtual ~CStreamStore();
sl@0
    52
	inline TStreamId ExtendL();
sl@0
    53
	IMPORT_C void Delete(TStreamId anId);
sl@0
    54
	IMPORT_C void DeleteL(TStreamId anId);
sl@0
    55
sl@0
    56
	virtual void CommitL() = 0;
sl@0
    57
sl@0
    58
	//
sl@0
    59
	// Internal store emulation functions
sl@0
    60
	//
sl@0
    61
	virtual store_private::MemStreamBuf *CreateStoreWriteStream() = 0;
sl@0
    62
	virtual store_private::MemStreamBuf *CreateStoreReadStream(TStreamId aId) const = 0;
sl@0
    63
	virtual bool Writable() const = 0;
sl@0
    64
	};
sl@0
    65
sl@0
    66
class CPersistentStore : public CStreamStore
sl@0
    67
	{
sl@0
    68
public:
sl@0
    69
	TStreamId Root();
sl@0
    70
	void SetRootL(TStreamId anId);
sl@0
    71
protected:
sl@0
    72
	TStreamId iRoot;
sl@0
    73
	};
sl@0
    74
sl@0
    75
class CFileStore : public CPersistentStore
sl@0
    76
	{
sl@0
    77
public:
sl@0
    78
	IMPORT_C void SetTypeL(const TUidType& aType);
sl@0
    79
	};
sl@0
    80
sl@0
    81
sl@0
    82
class CPermanentFileStore : public CFileStore
sl@0
    83
	{
sl@0
    84
public:
sl@0
    85
	static CFileStore *ReplaceLC(RFs &aFs, const TDesC &aName, TUint aFileMode);
sl@0
    86
	static CPermanentFileStore* OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode);
sl@0
    87
sl@0
    88
public:
sl@0
    89
	//
sl@0
    90
	// Internal store emulation functions
sl@0
    91
	//
sl@0
    92
	virtual store_private::MemStreamBuf *CreateStoreWriteStream();
sl@0
    93
	virtual store_private::MemStreamBuf *CreateStoreReadStream(TStreamId aId) const;
sl@0
    94
	virtual bool Writable() const;
sl@0
    95
private:
sl@0
    96
	CPermanentFileStore(const TDesC &aName, TUint aFileMode);
sl@0
    97
	virtual ~CPermanentFileStore();
sl@0
    98
	virtual void CommitL();
sl@0
    99
sl@0
   100
	void ReadInData();
sl@0
   101
	void ReadStreamData(TStreamId aStreamId, TInt aFrameOffset);
sl@0
   102
	
sl@0
   103
	bool iWritable;
sl@0
   104
	std::auto_ptr<RReadStream> iFileIn;
sl@0
   105
	std::auto_ptr<RWriteStream> iFileOut;
sl@0
   106
sl@0
   107
	TUint32 iLastStreamIdCreated;
sl@0
   108
	typedef std::map<TUint32, store_private::MemStreamBuf *> MemStreamBufPtrMap;
sl@0
   109
	MemStreamBufPtrMap iStreams;
sl@0
   110
	};
sl@0
   111
sl@0
   112
sl@0
   113
class RStoreWriteStream : public RWriteStream
sl@0
   114
	{
sl@0
   115
public:
sl@0
   116
	IMPORT_C TStreamId CreateLC(CStreamStore& aStore);
sl@0
   117
	};
sl@0
   118
sl@0
   119
class RStoreReadStream : public RReadStream
sl@0
   120
	{
sl@0
   121
public:
sl@0
   122
	RStoreReadStream();
sl@0
   123
	IMPORT_C void OpenLC(const CStreamStore& aStore, TStreamId aId);
sl@0
   124
	};
sl@0
   125
sl@0
   126
sl@0
   127
#endif