os/ossrv/lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/t_processfilemandeletefile.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/t_processfilemandeletefile.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,66 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Hepler process with high capability to perform deletion of files for
1.18 +// test harnesses.
1.19 +//
1.20 +//
1.21 +
1.22 +#include <f32file.h>
1.23 +#include <e32debug.h>
1.24 +#include <bautils.h>
1.25 +
1.26 +
1.27 +void DeleteFileL(const TDesC& aFile)
1.28 + {
1.29 + TInt r = KErrNone;
1.30 + RFs fs;
1.31 + r = fs.Connect();
1.32 + if (r != KErrNone)
1.33 + {
1.34 + User::Leave(r);
1.35 + }
1.36 + CleanupClosePushL(fs);
1.37 +
1.38 + CFileMan* fileMan = CFileMan::NewL(fs);
1.39 + CleanupStack::PushL(fileMan);
1.40 +
1.41 + // Make the file writeable and delete it.
1.42 + TInt err = fileMan->Attribs(aFile, 0, KEntryAttReadOnly, TTime(0), 0);
1.43 + if ((err != KErrNone) && (err != KErrNotFound) && (err != KErrPathNotFound))
1.44 + User::Leave(err);
1.45 +
1.46 + err = fileMan->Delete(aFile);
1.47 + if ((err != KErrNone) && (err != KErrPathNotFound))
1.48 + User::Leave(err);
1.49 +
1.50 + CleanupStack::PopAndDestroy(2);
1.51 + }
1.52 +
1.53 +GLDEF_C TInt E32Main()
1.54 + {
1.55 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.56 +
1.57 + TFileName name;
1.58 + User::CommandLine(name);
1.59 +
1.60 + TInt err = KErrNone;
1.61 + TRAP(err,DeleteFileL(name));
1.62 + if (err == KErrNone)
1.63 + RDebug::Print(_L("CFileMan Delete file '%S' succeeded.\n"), &name);
1.64 + else
1.65 + RDebug::Print(_L("CFileMan Delete file '%S' failed with error = %d.\n"), &name, err);
1.66 +
1.67 + delete cleanup;
1.68 + return err;
1.69 + }