messagingappbase/smilparser/SMILdtd/tsrc/t_LogFileWriter.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2001-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This class contains the functionality required to print
       
    15 // test data to a file.
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 #include "t_LogFileWriter.h"
       
    21 
       
    22 
       
    23 CTestDataWriter::CTestDataWriter()
       
    24 	{
       
    25 	}
       
    26 
       
    27 
       
    28 CTestDataWriter::~CTestDataWriter()
       
    29 	{
       
    30 	iFile.Close();
       
    31 	iFs.Close();
       
    32 	}
       
    33 
       
    34 
       
    35 CTestDataWriter* CTestDataWriter::NewL(const TDesC& aLogFileName)
       
    36 	{
       
    37 	CTestDataWriter* self = new (ELeave) CTestDataWriter();
       
    38 	CleanupStack::PushL(self);
       
    39 	self->ConstructL(aLogFileName);
       
    40 	CleanupStack::Pop();
       
    41 	return self;
       
    42 	}
       
    43 
       
    44 
       
    45 void CTestDataWriter::ConstructL(const TDesC& aLogFileName)
       
    46 	{
       
    47 	User::LeaveIfError(iFs.Connect());
       
    48 
       
    49 	// Open the file
       
    50 	TInt error = iFile.Open(iFs, aLogFileName, EFileShareAny | EFileStreamText | EFileWrite);
       
    51 
       
    52 	if (error != KErrNone)
       
    53 		{
       
    54 		User::LeaveIfError(iFile.Create(iFs, aLogFileName, EFileShareAny | EFileStreamText | EFileWrite));
       
    55 		}
       
    56 
       
    57 	iWriter.Set(iFile);	 // Set up the TFileText
       
    58 	}
       
    59 
       
    60 
       
    61 void CTestDataWriter::WriteTest(const TDesC& aLine)
       
    62 	{
       
    63 	iWriter.Write(aLine);
       
    64 	iFile.Flush();        // Commits the data to the file
       
    65 	}