Update contrib.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "filewriter.h"
25 #include "cryptospi/cryptospidef.h"
30 // a simple utility class to write to a text file given the path in its
33 CFileWriter* CFileWriter::NewL(TPtrC aFilePath)
35 CFileWriter* self=CFileWriter::NewLC(aFilePath);
36 CleanupStack::Pop(self);
40 CFileWriter* CFileWriter::NewLC(TPtrC aFilePath)
42 CFileWriter* self=new(ELeave) CFileWriter();
43 CleanupStack::PushL(self);
44 self->ConstructL(aFilePath);
49 CFileWriter::~CFileWriter()
51 // nulled in constructor so safe to call
58 CFileWriter::CFileWriter() : iFilePath(0)
62 void CFileWriter::WriteBlockL(TPtrC8 aData)
68 void CFileWriter::CreateFileL()
70 CleanupClosePushL(iRfs);
72 iRfs.Delete(iFilePath->Des());
74 User::LeaveIfError(iFile.Create(iRfs, iFilePath->Des(), EFileWrite));
76 CleanupStack::Pop(&iRfs);
79 void CFileWriter::ConstructL(TPtrC aFilePath)
81 iFilePath = HBufC::NewL(aFilePath.Length());
83 iFilePath->Des().Copy(aFilePath);
85 User::LeaveIfError(iRfs.Connect());