linklayercontrol/nullagt/TS_nullagt/src/NullagentPreCopy.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 26 Jan 2010 15:23:49 +0200
changeset 0 af10295192d8
permissions -rw-r--r--
Revision: 201004

// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "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:
// PRECOPY.CPP
// @file
// @internalComponent
// Pre Copy file preparation
// 
//

// EPOC includes
#include <e32base.h>
#include <f32file.h>

#include "NullAgentTestSteps.h"

//
//
// Test Pre Copy
/* This New Class is added to move copyfile command from script file
   This test does a copy operation 	
*/
CNullAgentPreCopy::CNullAgentPreCopy()
	{
	// store the name of this test case
	iTestStepName = _L("PreCopyTest");
	}

CNullAgentPreCopy::~CNullAgentPreCopy()
	{
	}

// Copy Test Main Code
enum TVerdict CNullAgentPreCopy::doTestStepL( void )
	{
	copyFileL(KSrcPath, KDestPath);
	return EPass;
	}


// Method to Copy a file to another file. 
void CNullAgentPreCopy::copyFileL (const TDesC& anOld,const TDesC& aNew) 
	{

	// create a fileserver
	RFs  FileSystem;

	// connect to file server
	TInt returnCode=FileSystem.Connect();

	// create a file manager
	CFileMan * fileMan = CFileMan::NewL( FileSystem );

	CleanupStack::PushL(fileMan);

	if (returnCode != KErrNone )
		{
		User::Leave(returnCode);
		}

	// parse the filenames
	TParse Source;
	returnCode = Source.Set( anOld, NULL, NULL );
	if ( returnCode != KErrNone )
		{
		User::Leave(returnCode);
		}
 
	// parse the filenames
	TParse Target;
	returnCode = Target.Set( aNew, NULL, NULL );
	if ( returnCode != KErrNone )
		{
		User::Leave(returnCode);
		}

	// do the copy
	returnCode=fileMan->Copy(Source.FullName(), 
		Target.FullName(), CFileMan::EOverWrite);

	if ( returnCode != KErrNone )
		{
			User::Leave(returnCode);
		}

	CleanupStack::PopAndDestroy(fileMan);
	// close the file system
	FileSystem.Close();
	}