lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/t_makefilewriteable.cpp
changeset 0 e4d67989cc36
child 44 97b0fb8a2cc2
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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_processdeletefile.cpp
       
    15 // Helper process with high capability to perform file operation for
       
    16 // test harnesses. 
       
    17 // 
       
    18 //
       
    19 
       
    20 #include <f32file.h>
       
    21 #include <e32debug.h>
       
    22 
       
    23 
       
    24 TInt DoMakeFileWriteableL(const TDesC& aFile)
       
    25 	{
       
    26 	// Make sure the file is not read-only
       
    27 	RDebug::Print(_L("Open for writing file %S\n"), &aFile);				
       
    28 	
       
    29 	RFs fs;
       
    30 	fs.Connect();
       
    31 	CFileMan* fileMan = CFileMan::NewL(fs);
       
    32 	CleanupStack::PushL(fileMan);
       
    33 	TInt err = fileMan->Attribs(aFile, 0, KEntryAttReadOnly, TTime(0), 0);
       
    34 	CleanupStack::PopAndDestroy(fileMan);
       
    35 	fs.Close();
       
    36 	return err;
       
    37 	}
       
    38 	
       
    39 static TInt MakeFileWriteable(const TDesC& aFile)
       
    40 	{	
       
    41 	TRAPD(err,DoMakeFileWriteableL(aFile));
       
    42 	return err;
       
    43 	}
       
    44 
       
    45 GLDEF_C TInt E32Main()
       
    46 	{
       
    47 	CTrapCleanup* cleanup =	CTrapCleanup::New(); 
       
    48 	
       
    49 	TFileName fileName;
       
    50 	User::CommandLine(fileName);
       
    51 	TInt err = MakeFileWriteable(fileName);	
       
    52 	delete cleanup;
       
    53 	return err;
       
    54 	}