messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionDeletePath.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2003-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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // DeletePath
       
    17 // [Action Parameters]
       
    18 // HBufC FilePath   <input>: Full path of the file or the folder to be deleted.
       
    19 // [Action Description]
       
    20 // Deletes the specified file or folder.
       
    21 // [APIs Used]
       
    22 // __ACTION_INFO_END__
       
    23 // 
       
    24 //
       
    25 
       
    26 /**
       
    27  @file
       
    28 */
       
    29 
       
    30 
       
    31 #include "CMtfTestActionDeletePath.h"
       
    32 #include "CMtfTestCase.h"
       
    33 #include "CMtfTestActionParameters.h"
       
    34 
       
    35 
       
    36 CMtfTestAction* CMtfTestActionDeletePath::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    37 	{
       
    38 	CMtfTestActionDeletePath* self = new (ELeave) CMtfTestActionDeletePath(aTestCase);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL(aActionParameters);
       
    41 	CleanupStack::Pop();
       
    42 	return self;
       
    43 	}
       
    44 	
       
    45 
       
    46 CMtfTestActionDeletePath::CMtfTestActionDeletePath(CMtfTestCase& aTestCase)
       
    47 	: CMtfSynchronousTestAction(aTestCase)
       
    48 	{
       
    49 	}
       
    50 
       
    51 
       
    52 CMtfTestActionDeletePath::~CMtfTestActionDeletePath()
       
    53 	{
       
    54 	}
       
    55 
       
    56 void CMtfTestActionDeletePath::ExecuteActionL()
       
    57 	{
       
    58 	TestCase().INFO_PRINTF1(_L("Test Action DeletePath start..."));
       
    59 	HBufC* paramPath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0));
       
    60 
       
    61 	TPtrC pathToDelete = paramPath->Des();
       
    62 
       
    63 	RFs fs;
       
    64 	User::LeaveIfError(fs.Connect());
       
    65 	CleanupClosePushL(fs);
       
    66 	
       
    67 	TParse parse;
       
    68 
       
    69 	parse.Set(pathToDelete, NULL, NULL);
       
    70 	TInt error;
       
    71 	if(parse.NamePresent())
       
    72 		{
       
    73 		// specified a file to delete
       
    74 		error = fs.Delete(parse.FullName());
       
    75 		}
       
    76 	else
       
    77 		{
       
    78 		// specified a directoy to delete
       
    79 		error = fs.RmDir(parse.DriveAndPath()); 
       
    80 		}
       
    81 	if (!(error==KErrNotFound||error==KErrNone))
       
    82 		{
       
    83 		User::Leave(error);
       
    84 		}
       
    85 	CleanupStack::PopAndDestroy(&fs);  // fs
       
    86 	TestCase().INFO_PRINTF1(_L("Test Action DeletePath completed."));
       
    87 	TestCase().ActionCompletedL(*this);
       
    88 	}
       
    89 
       
    90