linklayercontrol/nullagt/TS_nullagt/src/NullagentPreCopy.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2004-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 // PRECOPY.CPP
       
    15 // @file
       
    16 // @internalComponent
       
    17 // Pre Copy file preparation
       
    18 // 
       
    19 //
       
    20 
       
    21 // EPOC includes
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 #include "NullAgentTestSteps.h"
       
    26 
       
    27 //
       
    28 //
       
    29 // Test Pre Copy
       
    30 /* This New Class is added to move copyfile command from script file
       
    31    This test does a copy operation 	
       
    32 */
       
    33 CNullAgentPreCopy::CNullAgentPreCopy()
       
    34 	{
       
    35 	// store the name of this test case
       
    36 	iTestStepName = _L("PreCopyTest");
       
    37 	}
       
    38 
       
    39 CNullAgentPreCopy::~CNullAgentPreCopy()
       
    40 	{
       
    41 	}
       
    42 
       
    43 // Copy Test Main Code
       
    44 enum TVerdict CNullAgentPreCopy::doTestStepL( void )
       
    45 	{
       
    46 	copyFileL(KSrcPath, KDestPath);
       
    47 	return EPass;
       
    48 	}
       
    49 
       
    50 
       
    51 // Method to Copy a file to another file. 
       
    52 void CNullAgentPreCopy::copyFileL (const TDesC& anOld,const TDesC& aNew) 
       
    53 	{
       
    54 
       
    55 	// create a fileserver
       
    56 	RFs  FileSystem;
       
    57 
       
    58 	// connect to file server
       
    59 	TInt returnCode=FileSystem.Connect();
       
    60 
       
    61 	// create a file manager
       
    62 	CFileMan * fileMan = CFileMan::NewL( FileSystem );
       
    63 
       
    64 	CleanupStack::PushL(fileMan);
       
    65 
       
    66 	if (returnCode != KErrNone )
       
    67 		{
       
    68 		User::Leave(returnCode);
       
    69 		}
       
    70 
       
    71 	// parse the filenames
       
    72 	TParse Source;
       
    73 	returnCode = Source.Set( anOld, NULL, NULL );
       
    74 	if ( returnCode != KErrNone )
       
    75 		{
       
    76 		User::Leave(returnCode);
       
    77 		}
       
    78  
       
    79 	// parse the filenames
       
    80 	TParse Target;
       
    81 	returnCode = Target.Set( aNew, NULL, NULL );
       
    82 	if ( returnCode != KErrNone )
       
    83 		{
       
    84 		User::Leave(returnCode);
       
    85 		}
       
    86 
       
    87 	// do the copy
       
    88 	returnCode=fileMan->Copy(Source.FullName(), 
       
    89 		Target.FullName(), CFileMan::EOverWrite);
       
    90 
       
    91 	if ( returnCode != KErrNone )
       
    92 		{
       
    93 			User::Leave(returnCode);
       
    94 		}
       
    95 
       
    96 	CleanupStack::PopAndDestroy(fileMan);
       
    97 	// close the file system
       
    98 	FileSystem.Close();
       
    99 	}