lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/t_processfilemandeletefile.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 // Hepler process with high capability to perform deletion of files for
       
    15 // test harnesses. 
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <f32file.h>
       
    20 #include <e32debug.h>
       
    21 #include <bautils.h>
       
    22 
       
    23 
       
    24 void DeleteFileL(const TDesC& aFile)
       
    25 	{
       
    26 	RFs fs;
       
    27 	fs.Connect();
       
    28 	CleanupClosePushL(fs);
       
    29 	
       
    30 	CFileMan* fileMan = CFileMan::NewL(fs);
       
    31 	CleanupStack::PushL(fileMan);
       
    32 
       
    33     // Make the file writeable and delete it.
       
    34     TInt err = fileMan->Attribs(aFile, 0, KEntryAttReadOnly, TTime(0), 0);
       
    35 	if ((err != KErrNone) && (err != KErrNotFound) && (err != KErrPathNotFound))
       
    36 		User::Leave(err);
       
    37   
       
    38     err = fileMan->Delete(aFile);
       
    39     if ((err != KErrNone) && (err != KErrPathNotFound))
       
    40         User::Leave(err);
       
    41         
       
    42 	CleanupStack::PopAndDestroy(2); 
       
    43 	}
       
    44 	
       
    45 GLDEF_C TInt E32Main()
       
    46 	{
       
    47 	CTrapCleanup* cleanup =	CTrapCleanup::New(); 
       
    48 	
       
    49 	TFileName name;
       
    50 	User::CommandLine(name);
       
    51 
       
    52 	TInt err = KErrNone;	
       
    53 	TRAP(err,DeleteFileL(name));
       
    54 	if (err == KErrNone)
       
    55    		RDebug::Print(_L("CFileMan Delete file '%S' succeeded.\n"), &name);
       
    56 	else
       
    57     	RDebug::Print(_L("CFileMan Delete file '%S' failed with error = %d.\n"), &name, err);
       
    58 	
       
    59 	delete cleanup;
       
    60 	return err;
       
    61 	}