os/ossrv/lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/t_makefilewriteable.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/t_makefilewriteable.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,58 @@
     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 +// t_processdeletefile.cpp
    1.18 +// Helper process with high capability to perform file operation for
    1.19 +// test harnesses. 
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +#include <f32file.h>
    1.24 +#include <e32debug.h>
    1.25 +
    1.26 +
    1.27 +TInt DoMakeFileWriteableL(const TDesC& aFile)
    1.28 +	{
    1.29 +	// Make sure the file is not read-only
    1.30 +	RDebug::Print(_L("Open for writing file %S\n"), &aFile);				
    1.31 +	TInt r = KErrNone;
    1.32 +	RFs fs;
    1.33 +	r = fs.Connect();
    1.34 +	if (r != KErrNone)
    1.35 +		{
    1.36 +			User::Leave(r);
    1.37 +		}
    1.38 +	CFileMan* fileMan = CFileMan::NewL(fs);
    1.39 +	CleanupStack::PushL(fileMan);
    1.40 +	TInt err = fileMan->Attribs(aFile, 0, KEntryAttReadOnly, TTime(0), 0);
    1.41 +	CleanupStack::PopAndDestroy(fileMan);
    1.42 +	fs.Close();
    1.43 +	return err;
    1.44 +	}
    1.45 +	
    1.46 +static TInt MakeFileWriteable(const TDesC& aFile)
    1.47 +	{	
    1.48 +	TRAPD(err,DoMakeFileWriteableL(aFile));
    1.49 +	return err;
    1.50 +	}
    1.51 +
    1.52 +GLDEF_C TInt E32Main()
    1.53 +	{
    1.54 +	CTrapCleanup* cleanup =	CTrapCleanup::New(); 
    1.55 +	
    1.56 +	TFileName fileName;
    1.57 +	User::CommandLine(fileName);
    1.58 +	TInt err = MakeFileWriteable(fileName);	
    1.59 +	delete cleanup;
    1.60 +	return err;
    1.61 +	}