appinstaller/AppinstUi/Plugin/Tasks/FileTask/Src/FileTaskDelete.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This file contains the implementation of CFileTaskDelete
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <f32file.h>
       
    22 #include "FileTaskDelete.h"
       
    23 
       
    24 using namespace SwiUI;
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CFileTaskDelete::CFileTaskDelete
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CFileTaskDelete::CFileTaskDelete()
       
    35     {
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CFileTaskDelete::NewL
       
    40 // Two-phased constructor.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CFileTaskDelete* CFileTaskDelete::NewL()
       
    44     {
       
    45     return new(ELeave) CFileTaskDelete();    
       
    46     }
       
    47 
       
    48 // Destructor
       
    49 CFileTaskDelete::~CFileTaskDelete()
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CFileTaskDelete::ExecuteL
       
    55 // Executes the task.
       
    56 // (other items were commented in a header).
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CFileTaskDelete::ExecuteL()
       
    60     {
       
    61     RFs rfs;
       
    62     User::LeaveIfError( rfs.Connect() );
       
    63     CleanupClosePushL( rfs );    
       
    64     
       
    65     CFileMan* fileMan = CFileMan::NewL( rfs );
       
    66     CleanupStack::PushL( fileMan );
       
    67     
       
    68     TInt err( KErrNone );
       
    69     
       
    70     if ( TParsePtrC( iParam.iFile ).NameOrExtPresent() )
       
    71         {
       
    72         // We want to delete files only
       
    73         err = fileMan->Delete( iParam.iFile );
       
    74         }
       
    75     else
       
    76         {
       
    77         // We want to delete a directory
       
    78         err = fileMan->RmDir( iParam.iFile );
       
    79         }   
       
    80     
       
    81     CleanupStack::PopAndDestroy( fileMan );
       
    82     CleanupStack::PopAndDestroy(); // rfs    
       
    83     
       
    84     if ( err == KErrInUse )
       
    85         {
       
    86         User::Leave( err );        
       
    87         }    
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CFileTaskDelete::SetParameterL
       
    92 // Adds a parameter to the task.
       
    93 // (other items were commented in a header).
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CFileTaskDelete::SetParameterL( const TDesC8& aParam, TInt /*aIndex*/ )
       
    97     {
       
    98     TFileTaskDeleteParamPckg pckg( iParam );
       
    99     pckg.Copy( aParam );    
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CFileTaskDelete::ExternalizeL
       
   104 // Externalizes the task.
       
   105 // (other items were commented in a header).
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CFileTaskDelete::DoExternalizeL( RWriteStream& aStream ) const
       
   109     {
       
   110     aStream << iParam.iFile;    
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CFileTaskDelete::DoInternalizeL
       
   115 // Internalizes the task.
       
   116 // (other items were commented in a header).
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CFileTaskDelete::DoInternalizeL( RReadStream& aStream )
       
   120     {
       
   121     aStream >> iParam.iFile;    
       
   122     }
       
   123 
       
   124 //  End of File