appfw/apparchitecture/tef/TCmdLineExe.CPP
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 "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 // TCmdLineExe.CPP - to test commandline APIS
       
    15 // This exe is called in testCmdLinesAPIsL in T_CmdlnStep.CPP
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent - Internal Symbian test code 
       
    22 */
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <e32uid.h>
       
    26 #include <e32base.h>
       
    27 #include <e32test.h>
       
    28 #include <apacmdln.h>
       
    29 #include "T_CmdlnStep.h"
       
    30 
       
    31 
       
    32 // Global functions
       
    33 
       
    34 /**  This function gets the file handle from the commandline object. It returns KErrNone when successful in reading
       
    35      a file else it returns a system-wide error
       
    36 */
       
    37 
       
    38 TInt DoReadFileL()
       
    39 	{
       
    40 	RFile file;
       
    41 	TBuf8<8> fileRead;
       
    42     CApaCommandLine* cmdLine;
       
    43     TInt ret(0);
       
    44 	ret = CApaCommandLine::GetCommandLineFromProcessEnvironment(cmdLine);
       
    45 	User::LeaveIfError(ret);
       
    46 	CleanupStack::PushL(cmdLine);
       
    47 
       
    48 	cmdLine->GetFileByHandleL(file);
       
    49     ret = file.Read(fileRead);
       
    50 	file.Close();
       
    51     CleanupStack::PopAndDestroy(cmdLine); 
       
    52 	return ret;
       
    53 	}
       
    54 
       
    55 GLDEF_C TInt E32Main()
       
    56 	{
       
    57 
       
    58 
       
    59 	__UHEAP_MARK;
       
    60     CTrapCleanup *cleanup=CTrapCleanup::New();
       
    61    
       
    62    	if(cleanup == NULL)
       
    63 		{
       
    64 		return KErrNoMemory;
       
    65 		}
       
    66     TInt val(0);
       
    67     
       
    68     TRAPD(err,val= DoReadFileL());
       
    69     delete(cleanup);
       
    70 	__UHEAP_MARKEND;
       
    71     
       
    72     if((err==KErrNone) && (val ==KErrNone ))
       
    73     	{
       
    74     		return KFileHandleTestPassed;
       
    75     	}
       
    76     else
       
    77     	{
       
    78     		return KErrGeneral;
       
    79     	}
       
    80 
       
    81 	}
       
    82 	
       
    83 
       
    84