|
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 // t_processfilemandeletefile.cpp |
|
15 // Hepler process with high capability to perform deletion of files for |
|
16 // test harnesses. |
|
17 // |
|
18 // |
|
19 |
|
20 #include <f32file.h> |
|
21 #include <e32debug.h> |
|
22 #include <bautils.h> |
|
23 |
|
24 |
|
25 TInt DoDeleteDirL(const TDesC& aPath) |
|
26 { |
|
27 RFs fs; |
|
28 fs.Connect(); |
|
29 CFileMan* fileMan = CFileMan::NewL(fs); |
|
30 CleanupStack::PushL(fileMan); |
|
31 |
|
32 // Make the file writeable |
|
33 TInt err = fileMan->Attribs(aPath, 0, KEntryAttReadOnly, TTime(0), 0); |
|
34 // Delete file using CFileMan |
|
35 err = fileMan->RmDir(aPath); |
|
36 RDebug::Print(_L("CFileMan Delete file %S - err = %d\n"), &aPath, err); |
|
37 |
|
38 CleanupStack::PopAndDestroy(fileMan); |
|
39 fs.Close(); |
|
40 return err; |
|
41 } |
|
42 |
|
43 static TInt DeleteDir(const TDesC& aPath) |
|
44 { |
|
45 TRAPD(err,DoDeleteDirL(aPath)); |
|
46 return err; |
|
47 } |
|
48 |
|
49 GLDEF_C TInt E32Main() |
|
50 { |
|
51 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
52 |
|
53 TFileName name; |
|
54 User::CommandLine(name); |
|
55 TInt err = DeleteDir(name); |
|
56 delete cleanup; |
|
57 return err; |
|
58 } |