sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Hepler process with high capability to perform deletion of files for sl@0: // test harnesses. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: void DeleteFileL(const TDesC& aFile) sl@0: { sl@0: TInt r = KErrNone; sl@0: RFs fs; sl@0: r = fs.Connect(); sl@0: if (r != KErrNone) sl@0: { sl@0: User::Leave(r); sl@0: } sl@0: CleanupClosePushL(fs); sl@0: sl@0: CFileMan* fileMan = CFileMan::NewL(fs); sl@0: CleanupStack::PushL(fileMan); sl@0: sl@0: // Make the file writeable and delete it. sl@0: TInt err = fileMan->Attribs(aFile, 0, KEntryAttReadOnly, TTime(0), 0); sl@0: if ((err != KErrNone) && (err != KErrNotFound) && (err != KErrPathNotFound)) sl@0: User::Leave(err); sl@0: sl@0: err = fileMan->Delete(aFile); sl@0: if ((err != KErrNone) && (err != KErrPathNotFound)) sl@0: User::Leave(err); sl@0: sl@0: CleanupStack::PopAndDestroy(2); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: sl@0: TFileName name; sl@0: User::CommandLine(name); sl@0: sl@0: TInt err = KErrNone; sl@0: TRAP(err,DeleteFileL(name)); sl@0: if (err == KErrNone) sl@0: RDebug::Print(_L("CFileMan Delete file '%S' succeeded.\n"), &name); sl@0: else sl@0: RDebug::Print(_L("CFileMan Delete file '%S' failed with error = %d.\n"), &name, err); sl@0: sl@0: delete cleanup; sl@0: return err; sl@0: }