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: // t_processdeletefile.cpp sl@0: // Helper process with high capability to perform file operation for sl@0: // test harnesses. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: TInt DoMakeFileWriteableL(const TDesC& aFile) sl@0: { sl@0: // Make sure the file is not read-only sl@0: RDebug::Print(_L("Open for writing file %S\n"), &aFile); 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: CFileMan* fileMan = CFileMan::NewL(fs); sl@0: CleanupStack::PushL(fileMan); sl@0: TInt err = fileMan->Attribs(aFile, 0, KEntryAttReadOnly, TTime(0), 0); sl@0: CleanupStack::PopAndDestroy(fileMan); sl@0: fs.Close(); sl@0: return err; sl@0: } sl@0: sl@0: static TInt MakeFileWriteable(const TDesC& aFile) sl@0: { sl@0: TRAPD(err,DoMakeFileWriteableL(aFile)); sl@0: return err; sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: sl@0: TFileName fileName; sl@0: User::CommandLine(fileName); sl@0: TInt err = MakeFileWriteable(fileName); sl@0: delete cleanup; sl@0: return err; sl@0: }