First public contribution.
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 "OldEZFilebuffer.h"
17 #include "OldEZstream.h"
19 using namespace TOLDEZLIB;
21 _LIT(KFileBuffer,"FileBuffer");
23 void CEZFileBufferManager::ConstructL(TInt aBufferSize)
25 __ASSERT_ALWAYS(aBufferSize > 0, User::Panic(KFileBuffer, EBadInitialization));
27 iBufferSize = aBufferSize;
29 iInputBuffer = new (ELeave) TUint8[iBufferSize];
30 iOutputBuffer = new (ELeave) TUint8[iBufferSize];
32 iInputDescriptor.Set(iInputBuffer,0,iBufferSize);
33 iOutputDescriptor.Set(iOutputBuffer,0,iBufferSize);
36 CEZFileBufferManager::~CEZFileBufferManager()
38 delete[] iInputBuffer;
39 delete[] iOutputBuffer;
42 CEZFileBufferManager::CEZFileBufferManager(RFile &aInput, RFile &aOutput) :
43 iInputFile(aInput), iOutputFile(aOutput), iInputDescriptor(NULL,0), iOutputDescriptor(NULL,0)
49 Creates a new CEZFileBufferManager object and leave it on the CleanupStack
51 @param aInput the input file
52 @param aOutput the output file
53 @param aBufferSize the required size of the buffers
54 @return the new CEZFileBufferManager object, on the CleanupStack
56 EXPORT_C CEZFileBufferManager* CEZFileBufferManager::NewLC(RFile &aInput, RFile &aOutput, TInt aBufferSize)
58 CEZFileBufferManager *fb = new (ELeave) CEZFileBufferManager(aInput,aOutput);
59 CleanupStack::PushL(fb);
60 fb->ConstructL(aBufferSize);
65 Creates a new CEZFileBufferManager object
67 @param aInput the input file
68 @param aOutput the output file
69 @param aBufferSize the required size of the buffers
70 @return the new CEZFileBufferManager object
72 EXPORT_C CEZFileBufferManager* CEZFileBufferManager::NewL(RFile &aInput, RFile &aOutput, TInt aBufferSize)
74 CEZFileBufferManager *fb = new (ELeave) CEZFileBufferManager(aInput,aOutput);
75 CleanupStack::PushL(fb);
76 fb->ConstructL(aBufferSize);
82 void CEZFileBufferManager::InitializeL(CEZZStream &aZStream)
84 User::LeaveIfError(iInputFile.Read(iInputDescriptor));
85 aZStream.SetInput(iInputDescriptor);
86 aZStream.SetOutput(iOutputDescriptor);
89 void CEZFileBufferManager::NeedInputL(CEZZStream &aZStream)
91 User::LeaveIfError(iInputFile.Read(iInputDescriptor));
92 aZStream.SetInput(iInputDescriptor);
95 void CEZFileBufferManager::NeedOutputL(CEZZStream &aZStream)
97 TPtrC8 od = aZStream.OutputDescriptor();
98 User::LeaveIfError(iOutputFile.Write(od));
99 aZStream.SetOutput(iOutputDescriptor);
102 void CEZFileBufferManager::FinalizeL(CEZZStream &aZStream)
104 TPtrC8 od = aZStream.OutputDescriptor();
105 User::LeaveIfError(iOutputFile.Write(od));