1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/TSUtils/TTaskFileChecker.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,71 @@
1.4 +// Copyright (c) 2006-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 +// TTaskFilesChecker.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <f32file.h>
1.22 +#include <e32debug.h>
1.23 +
1.24 +// This function is used in the test code to check if there's any task files left
1.25 +// after scheduled tasks completed
1.26 +
1.27 +_LIT(KTaskFileScanDir, "_:\\Private\\10005399\\");
1.28 +
1.29 +_LIT(KTaskFileWildname, "*.tmp");
1.30 +
1.31 +static TInt CheckTaskFilesL()
1.32 + {
1.33 + RFs fs;
1.34 + User::LeaveIfError(fs.Connect());
1.35 +
1.36 + //Get the correct system drive
1.37 + TBuf<32> taskFilePath(KTaskFileScanDir);
1.38 + taskFilePath[0] = RFs::GetSystemDriveChar();
1.39 +
1.40 + // Search for task files using wildcard file name
1.41 + TFindFile fileFinder(fs);
1.42 + CDir* fileList = NULL;
1.43 + TInt rel = fileFinder.FindWildByDir(KTaskFileWildname, taskFilePath, fileList);
1.44 +
1.45 + // delete file list, we won't use it
1.46 + if (fileList != NULL)
1.47 + delete fileList;
1.48 +
1.49 + // When any task file found left, leave with error code KErrGeneral
1.50 + if (rel == KErrNone)
1.51 + rel = KErrGeneral;
1.52 +
1.53 + // When there's no task file left, return KErrNone
1.54 + if (rel == KErrNotFound)
1.55 + rel = KErrNone;
1.56 +
1.57 + // Leave with KErrGeneral or any other error
1.58 + User::LeaveIfError(rel);
1.59 + return rel;
1.60 + }
1.61 +
1.62 +
1.63 +GLDEF_C TInt E32Main()
1.64 + {
1.65 + TInt err = KErrNoMemory;
1.66 + CTrapCleanup* cleanup=CTrapCleanup::New(); //can fail
1.67 + if (cleanup)
1.68 + {
1.69 + err = KErrNone;
1.70 + TRAP(err, CheckTaskFilesL())
1.71 + delete cleanup;
1.72 + }
1.73 + return err;
1.74 + }