Update contrib.
1 // Copyright (c) 2003-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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <ezfilebuffer.h>
19 _LIT(KFileBuffer,"FileBuffer");
21 void CEZFileBufferManager::ConstructL(TInt aBufferSize)
23 __ASSERT_ALWAYS(aBufferSize > 0, User::Panic(KFileBuffer, EBadInitialization));
25 iBufferSize = aBufferSize;
27 iInputBuffer = new (ELeave) TUint8[iBufferSize];
28 iOutputBuffer = new (ELeave) TUint8[iBufferSize];
30 iInputDescriptor.Set(iInputBuffer,0,iBufferSize);
31 iOutputDescriptor.Set(iOutputBuffer,0,iBufferSize);
34 CEZFileBufferManager::~CEZFileBufferManager()
36 delete[] iInputBuffer;
37 delete[] iOutputBuffer;
40 CEZFileBufferManager::CEZFileBufferManager(RFile &aInput, RFile &aOutput) :
41 iInputFile(aInput), iOutputFile(aOutput), iInputDescriptor(NULL,0), iOutputDescriptor(NULL,0)
47 Creates a new CEZFileBufferManager object and leave it on the CleanupStack
49 @param aInput the input file
50 @param aOutput the output file
51 @param aBufferSize the required size of the buffers
52 @return the new CEZFileBufferManager object, on the CleanupStack
54 EXPORT_C CEZFileBufferManager* CEZFileBufferManager::NewLC(RFile &aInput, RFile &aOutput, TInt aBufferSize)
56 CEZFileBufferManager *fb = new (ELeave) CEZFileBufferManager(aInput,aOutput);
57 CleanupStack::PushL(fb);
58 fb->ConstructL(aBufferSize);
63 Creates a new CEZFileBufferManager object
65 @param aInput the input file
66 @param aOutput the output file
67 @param aBufferSize the required size of the buffers
68 @return the new CEZFileBufferManager object
70 EXPORT_C CEZFileBufferManager* CEZFileBufferManager::NewL(RFile &aInput, RFile &aOutput, TInt aBufferSize)
72 CEZFileBufferManager *fb = new (ELeave) CEZFileBufferManager(aInput,aOutput);
73 CleanupStack::PushL(fb);
74 fb->ConstructL(aBufferSize);
80 void CEZFileBufferManager::InitializeL(CEZZStream &aZStream)
82 User::LeaveIfError(iInputFile.Read(iInputDescriptor));
83 aZStream.SetInput(iInputDescriptor);
84 aZStream.SetOutput(iOutputDescriptor);
87 void CEZFileBufferManager::NeedInputL(CEZZStream &aZStream)
89 User::LeaveIfError(iInputFile.Read(iInputDescriptor));
90 aZStream.SetInput(iInputDescriptor);
93 void CEZFileBufferManager::NeedOutputL(CEZZStream &aZStream)
95 TPtrC8 od = aZStream.OutputDescriptor();
96 User::LeaveIfError(iOutputFile.Write(od));
97 aZStream.SetOutput(iOutputDescriptor);
100 void CEZFileBufferManager::FinalizeL(CEZZStream &aZStream)
102 TPtrC8 od = aZStream.OutputDescriptor();
103 User::LeaveIfError(iOutputFile.Write(od));