First public contribution.
1 // Copyright (c) 2004-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.
21 //This function is used in the test code to kill SCHSVR or MinimalTaskHandler
22 //processes (or some other) when they leftover and may cause OOM condinitons.
23 static TInt DeleteScheduleFilesL()
26 _LIT(KFilePath, "_:\\Private\\10005399\\*.*");
28 //Get the correct system drive
29 TBuf<32> filePath(KFilePath);
30 filePath[0] = RFs::GetSystemDriveChar();
32 User::LeaveIfError(fs.Connect());
33 CleanupClosePushL(fs);
34 CFileMan* fileManager = CFileMan::NewL(fs);
35 CleanupStack::PushL(fileManager);
36 TInt ret = fileManager->Delete(filePath);
37 if(ret != KErrNone && ret != KErrNotFound && ret != KErrPathNotFound)
39 RDebug::Print(_L("DeleteScheduleFilesL - err=%d\n"), ret);
40 //Resource/memory/file deallocation is not the right place for User::Leave() call!
41 //Sometimes fileManager->Delete() fails with error "-14" (KErrInUse),
42 //because SCHSVR server is alive!
45 CleanupStack::PopAndDestroy(fileManager);
46 CleanupStack::PopAndDestroy(); //fs
50 GLDEF_C TInt E32Main()
52 TInt err = KErrNoMemory;
53 CTrapCleanup* cleanup=CTrapCleanup::New(); //can fail
57 TRAP(err, DeleteScheduleFilesL())