genericservices/taskscheduler/Test/TSUtils/TTaskFileChecker.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2006-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 // TTaskFilesChecker.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <f32file.h>
       
    19 #include <e32debug.h>
       
    20 
       
    21 // This function is used in the test code to check if there's any task files left
       
    22 // after scheduled tasks completed
       
    23 
       
    24 _LIT(KTaskFileScanDir, "_:\\Private\\10005399\\");
       
    25 
       
    26 _LIT(KTaskFileWildname, "*.tmp");
       
    27 
       
    28 static TInt CheckTaskFilesL()
       
    29 	{
       
    30 	RFs fs;
       
    31 	User::LeaveIfError(fs.Connect());
       
    32 	
       
    33 	//Get the correct system drive
       
    34 	TBuf<32> taskFilePath(KTaskFileScanDir);
       
    35 	taskFilePath[0] = RFs::GetSystemDriveChar();
       
    36 	
       
    37 	// Search for task files using wildcard file name
       
    38 	TFindFile fileFinder(fs);
       
    39 	CDir* fileList = NULL;
       
    40 	TInt rel = fileFinder.FindWildByDir(KTaskFileWildname, taskFilePath, fileList);
       
    41 	
       
    42 	// delete file list, we won't use it
       
    43 	if (fileList != NULL)
       
    44 		delete fileList;
       
    45 						
       
    46 	// When any task file found left, leave with error code KErrGeneral
       
    47 	if (rel == KErrNone)
       
    48 		rel = KErrGeneral;
       
    49 		
       
    50 	// When there's no task file left, return KErrNone
       
    51 	if (rel == KErrNotFound)
       
    52 		rel = KErrNone;
       
    53 		
       
    54 	// Leave with KErrGeneral or any other error	
       
    55 	User::LeaveIfError(rel);
       
    56 	return rel;
       
    57 	}
       
    58 	
       
    59 
       
    60 GLDEF_C TInt E32Main()
       
    61 	{
       
    62 	TInt err = KErrNoMemory;
       
    63 	CTrapCleanup* cleanup=CTrapCleanup::New();	//can fail
       
    64 	if (cleanup)
       
    65 		{
       
    66 		err = KErrNone;
       
    67 		TRAP(err, CheckTaskFilesL())
       
    68 		delete cleanup;
       
    69 		}
       
    70 	return err;
       
    71 	}