sl@0: /*
sl@0: * Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: * All rights reserved.
sl@0: * This component and the accompanying materials are made available
sl@0: * under the terms of "Eclipse Public License v1.0"
sl@0: * which accompanies this distribution, and is available
sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: *
sl@0: * Initial Contributors:
sl@0: * Nokia Corporation - initial contribution.
sl@0: *
sl@0: * Contributors:
sl@0: *
sl@0: * Description: 
sl@0: *
sl@0: */
sl@0: 
sl@0: 
sl@0: #include "T_InvalidFontFile.h"
sl@0: #include <e32std.h>
sl@0: #include <f32file.h>
sl@0: #include <s32file.h>
sl@0: 
sl@0: 
sl@0: /**
sl@0: Simple application to create an invalid font file for use in the Font Store eclipsing tests
sl@0: This app is seperate from the test code so that it may use the Tcb capability in order to
sl@0: write to the \resource\* directory.
sl@0: */
sl@0: LOCAL_C void MainL()
sl@0: 	{
sl@0: 	RFs fs;
sl@0: 	CleanupClosePushL(fs);
sl@0: 	User::LeaveIfError(fs.Connect());
sl@0: 
sl@0: 	RFileWriteStream fw;
sl@0: 	CleanupClosePushL(fw);
sl@0: 	
sl@0: 	//Ensure the directory exists or the file writing will fail
sl@0: 	TRAPD(err, fs.MkDirAll(KEclipsingFolder));
sl@0: 	if (err != KErrAlreadyExists)
sl@0: 		User::LeaveIfError(err);
sl@0: 	
sl@0: 	//Create the invalid file
sl@0: 	User::LeaveIfError(fw.Create(fs, KEclipsingFile, EFileWrite));
sl@0: 	fw.WriteL(KInvalidFontFileText);
sl@0: 	fw.CommitL();
sl@0: 
sl@0: 	CleanupStack::PopAndDestroy(2, &fs);
sl@0: 	}
sl@0: 
sl@0: GLDEF_C TInt E32Main()
sl@0: 	{
sl@0: 	__UHEAP_MARK;
sl@0: 	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0: 	TRAPD(mainError, MainL());
sl@0: 	if (mainError != KErrNone)
sl@0: 		{
sl@0: 		RDebug::Printf("T_WriteInvalidFontFile.exe failed with error %i", mainError);
sl@0: 		}
sl@0: 	delete cleanup;
sl@0: 	__UHEAP_MARKEND;
sl@0: 	return KErrNone;
sl@0: 	}
sl@0: