sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// TTaskFilesChecker.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include <e32debug.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
// This function is used in the test code to check if there's any task files left
|
sl@0
|
22 |
// after scheduled tasks completed
|
sl@0
|
23 |
|
sl@0
|
24 |
_LIT(KTaskFileScanDir, "_:\\Private\\10005399\\");
|
sl@0
|
25 |
|
sl@0
|
26 |
_LIT(KTaskFileWildname, "*.tmp");
|
sl@0
|
27 |
|
sl@0
|
28 |
static TInt CheckTaskFilesL()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
RFs fs;
|
sl@0
|
31 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
32 |
|
sl@0
|
33 |
//Get the correct system drive
|
sl@0
|
34 |
TBuf<32> taskFilePath(KTaskFileScanDir);
|
sl@0
|
35 |
taskFilePath[0] = RFs::GetSystemDriveChar();
|
sl@0
|
36 |
|
sl@0
|
37 |
// Search for task files using wildcard file name
|
sl@0
|
38 |
TFindFile fileFinder(fs);
|
sl@0
|
39 |
CDir* fileList = NULL;
|
sl@0
|
40 |
TInt rel = fileFinder.FindWildByDir(KTaskFileWildname, taskFilePath, fileList);
|
sl@0
|
41 |
|
sl@0
|
42 |
// delete file list, we won't use it
|
sl@0
|
43 |
if (fileList != NULL)
|
sl@0
|
44 |
delete fileList;
|
sl@0
|
45 |
|
sl@0
|
46 |
// When any task file found left, leave with error code KErrGeneral
|
sl@0
|
47 |
if (rel == KErrNone)
|
sl@0
|
48 |
rel = KErrGeneral;
|
sl@0
|
49 |
|
sl@0
|
50 |
// When there's no task file left, return KErrNone
|
sl@0
|
51 |
if (rel == KErrNotFound)
|
sl@0
|
52 |
rel = KErrNone;
|
sl@0
|
53 |
|
sl@0
|
54 |
// Leave with KErrGeneral or any other error
|
sl@0
|
55 |
User::LeaveIfError(rel);
|
sl@0
|
56 |
return rel;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
|
sl@0
|
60 |
GLDEF_C TInt E32Main()
|
sl@0
|
61 |
{
|
sl@0
|
62 |
TInt err = KErrNoMemory;
|
sl@0
|
63 |
CTrapCleanup* cleanup=CTrapCleanup::New(); //can fail
|
sl@0
|
64 |
if (cleanup)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
err = KErrNone;
|
sl@0
|
67 |
TRAP(err, CheckTaskFilesL())
|
sl@0
|
68 |
delete cleanup;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
return err;
|
sl@0
|
71 |
}
|