|
1 // Copyright (c) 2005-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TCmdLineExe.CPP - to test commandline APIS |
|
15 // This exe is called in testCmdLinesAPIsL in T_CmdlnStep.CPP |
|
16 // |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <e32uid.h> |
|
28 #include <e32base.h> |
|
29 #include <e32test.h> |
|
30 #include <apacmdln.h> |
|
31 #include "T_CmdlnStep.h" |
|
32 |
|
33 |
|
34 // Global functions |
|
35 |
|
36 /** This function gets the file handle from the commandline object. It returns KErrNone when successful in reading |
|
37 a file else it returns a system-wide error |
|
38 */ |
|
39 |
|
40 TInt DoReadFileL() |
|
41 { |
|
42 RFile file; |
|
43 TBuf8<8> fileRead; |
|
44 CApaCommandLine* cmdLine; |
|
45 TInt ret(0); |
|
46 ret = CApaCommandLine::GetCommandLineFromProcessEnvironment(cmdLine); |
|
47 User::LeaveIfError(ret); |
|
48 CleanupStack::PushL(cmdLine); |
|
49 |
|
50 cmdLine->GetFileByHandleL(file); |
|
51 ret = file.Read(fileRead); |
|
52 file.Close(); |
|
53 CleanupStack::PopAndDestroy(cmdLine); |
|
54 return ret; |
|
55 } |
|
56 |
|
57 GLDEF_C TInt E32Main() |
|
58 { |
|
59 |
|
60 |
|
61 __UHEAP_MARK; |
|
62 CTrapCleanup *cleanup=CTrapCleanup::New(); |
|
63 |
|
64 if(cleanup == NULL) |
|
65 { |
|
66 return KErrNoMemory; |
|
67 } |
|
68 TInt val(0); |
|
69 |
|
70 TRAPD(err,val= DoReadFileL()); |
|
71 delete(cleanup); |
|
72 __UHEAP_MARKEND; |
|
73 |
|
74 if((err==KErrNone) && (val ==KErrNone )) |
|
75 { |
|
76 return KFileHandleTestPassed; |
|
77 } |
|
78 else |
|
79 { |
|
80 return KErrGeneral; |
|
81 } |
|
82 |
|
83 } |
|
84 |