os/ossrv/genericservices/taskscheduler/Test/TSUtils/TTaskFileCreator.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/TSUtils/TTaskFileCreator.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,76 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <f32file.h>
    1.20 +#include <e32debug.h>
    1.21 +
    1.22 +// This function is used in the test code to create dummy test files to verify
    1.23 +//that these files are deleted by the task scheduler on startup 
    1.24 +_LIT(KTaskFile1Name, "_:\\Private\\10005399\\12345678901234567890.tmp");
    1.25 +_LIT(KTaskFile2Name, "_:\\Private\\10005399\\98765432100123456789.tmp");
    1.26 +_LIT(KTaskFile3Name, "_:\\Private\\10005399\\98765432109876543210.tmp");
    1.27 +
    1.28 +static TInt CreateFileL(const TDesC& aFileName)
    1.29 +	{
    1.30 +	RFs fs;
    1.31 +	RFile taskFile;
    1.32 +	
    1.33 +	User::LeaveIfError(fs.Connect());
    1.34 +	
    1.35 +	//Get the correct system drive
    1.36 +	TBuf<64> filePath(aFileName);
    1.37 +	filePath[0] = RFs::GetSystemDriveChar();
    1.38 +	
    1.39 +	//Create the temp file
    1.40 +	TInt res = taskFile.Create(fs,filePath,EFileRead);
    1.41 +	taskFile.Close();
    1.42 +	
    1.43 +	fs.Close();
    1.44 +	
    1.45 +	return res;	
    1.46 +	}
    1.47 +	
    1.48 +static TInt CreateTaskFilesL()
    1.49 +	{
    1.50 +
    1.51 +	//Create the temp file
    1.52 +	TInt res = CreateFileL(KTaskFile1Name);
    1.53 +		
    1.54 +	if(res ==KErrNone)
    1.55 +	{
    1.56 +	res = CreateFileL(KTaskFile2Name);	
    1.57 +	}
    1.58 +	
    1.59 +	if(res ==KErrNone)
    1.60 +	{
    1.61 +	res = CreateFileL(KTaskFile3Name);	
    1.62 +	}
    1.63 +	
    1.64 +	return res;
    1.65 +	}
    1.66 +		
    1.67 +
    1.68 +GLDEF_C TInt E32Main()
    1.69 +	{
    1.70 +	TInt err = KErrNoMemory;
    1.71 +	CTrapCleanup* cleanup=CTrapCleanup::New();	//can fail
    1.72 +	if (cleanup)
    1.73 +		{
    1.74 +		err = KErrNone;
    1.75 +		TRAP(err, CreateTaskFilesL())
    1.76 +		delete cleanup;
    1.77 +		}
    1.78 +	return err;
    1.79 +	}