common/tools/ats/smoketest/localisation/apparchitecture/tef/TCmdLineExe.CPP
author Simon Howkins <simonh@symbian.org>
Wed, 27 Oct 2010 16:22:14 +0100
changeset 1316 0b4a09013baf
parent 872 17498133d9ad
permissions -rw-r--r--
Added copyright messages

// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// TCmdLineExe.CPP - to test commandline APIS
// This exe is called in testCmdLinesAPIsL in T_CmdlnStep.CPP
// 
//



/**
 @file
 @internalComponent - Internal Symbian test code 
*/

#include <e32std.h>
#include <e32uid.h>
#include <e32base.h>
#include <e32test.h>
#include  <apacmdln.h>
#include "T_CmdlnStep.h"


// Global functions

/**  This function gets the file handle from the commandline object. It returns KErrNone when successful in reading
     a file else it returns a system-wide error
*/

TInt DoReadFileL()
	{
	RFile file;
	TBuf8<8> fileRead;
    CApaCommandLine* cmdLine;
    TInt ret(0);
	ret = CApaCommandLine::GetCommandLineFromProcessEnvironment(cmdLine);
	User::LeaveIfError(ret);
	CleanupStack::PushL(cmdLine);

	cmdLine->GetFileByHandleL(file);
    ret = file.Read(fileRead);
	file.Close();
    CleanupStack::PopAndDestroy(cmdLine); 
	return ret;
	}

GLDEF_C TInt E32Main()
	{


	__UHEAP_MARK;
    CTrapCleanup *cleanup=CTrapCleanup::New();
   
   	if(cleanup == NULL)
		{
		return KErrNoMemory;
		}
    TInt val(0);
    
    TRAPD(err,val= DoReadFileL());
    delete(cleanup);
	__UHEAP_MARKEND;
    
    if((err==KErrNone) && (val ==KErrNone ))
    	{
    		return KFileHandleTestPassed;
    	}
    else
    	{
    		return KErrGeneral;
    	}

	}