|
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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // RenamePath |
|
17 // [Action Parameters] |
|
18 // HBufC FilePath <input>: Full path of the file or the folder to be renamed. |
|
19 // HBufC FilePath <input>: New file path. |
|
20 // [Action Description] |
|
21 // Renames the specified file or folder. |
|
22 // [APIs Used] |
|
23 // __ACTION_INFO_END__ |
|
24 // |
|
25 // |
|
26 |
|
27 |
|
28 #include "CMtfTestActionRenamePath.h" |
|
29 #include "CMtfTestCase.h" |
|
30 #include "CMtfTestActionParameters.h" |
|
31 |
|
32 |
|
33 CMtfTestAction* CMtfTestActionRenamePath::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
34 { |
|
35 CMtfTestActionRenamePath* self = new (ELeave) CMtfTestActionRenamePath(aTestCase); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(aActionParameters); |
|
38 CleanupStack::Pop(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 CMtfTestActionRenamePath::CMtfTestActionRenamePath(CMtfTestCase& aTestCase) |
|
44 : CMtfSynchronousTestAction(aTestCase) |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 CMtfTestActionRenamePath::~CMtfTestActionRenamePath() |
|
50 { |
|
51 } |
|
52 |
|
53 void CMtfTestActionRenamePath::ExecuteActionL() |
|
54 { |
|
55 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRenamePath); |
|
56 HBufC* paramPath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0)); |
|
57 HBufC* paramNewPath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1)); |
|
58 |
|
59 TPtrC pathToRename = paramPath->Des(); |
|
60 TPtrC newPath = paramNewPath->Des(); |
|
61 |
|
62 RFs fs; |
|
63 User::LeaveIfError(fs.Connect()); |
|
64 CleanupClosePushL(fs); |
|
65 |
|
66 TParse parseRenamePath; |
|
67 TParse parseNewPath; |
|
68 |
|
69 parseRenamePath.Set(pathToRename, NULL, NULL); |
|
70 parseNewPath.Set(newPath, NULL, NULL); |
|
71 |
|
72 TInt error; |
|
73 |
|
74 error = fs.Rename(parseRenamePath.FullName(), parseNewPath.FullName()); |
|
75 |
|
76 if (!(error==KErrNone)) |
|
77 { |
|
78 User::Leave(error); |
|
79 } |
|
80 CleanupStack::PopAndDestroy(&fs); // fs |
|
81 |
|
82 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRenamePath); |
|
83 TestCase().ActionCompletedL(*this); |
|
84 } |