sl@0: // Copyright (c) 2006-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: // 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: void DoMakeFileReadOnlyL(const TDesC& aFile) sl@0: { sl@0: // Setting read only flag for a file sl@0: RDebug::Print(_L("Making file read only %S\n"), &aFile); sl@0: sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: CFileMan* fileMan = CFileMan::NewL(fs); sl@0: TInt err = fileMan->Attribs(aFile,KEntryAttReadOnly,KEntryAttNormal,TTime(0),0); sl@0: delete fileMan; sl@0: CleanupStack::PopAndDestroy(); // fs.Close() sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: static TInt MakeFileReadOnly(const TDesC& aFile) sl@0: { sl@0: TRAPD(err, DoMakeFileReadOnlyL(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 = MakeFileReadOnly(fileName); sl@0: delete cleanup; sl@0: return err; sl@0: }