harvester/monitorplugins/inc/fsutil.inl
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 18 Jan 2010 20:34:07 +0200
changeset 0 c53acadfccc6
child 15 3cebc1a84278
permissions -rw-r--r--
Revision: 201001 Kit: 201003

/*
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Some generic utilities.*
*/


#include "mdscommoninternal.h"
#include "mdeharvestersession.h"
#include <e32base.h>

inline TUint32 FSUtil::MediaID( const RFs& aFs, TInt aDrive )
    {
    TVolumeInfo vi;
    
    TInt err = aFs.Volume(vi, aDrive);
    if(err == KErrNone)
        {
        return vi.iUniqueID;
        }
        
    return 0;
    }

inline TUint32 FSUtil::MediaID( const RFs& aFs, const TDesC& aUri )
    {
    TInt drive = DriveNumber(aUri);
    if(drive == -1)
        {
        return 0;
        }
        
    return MediaID(aFs, drive);
    }

inline TUint32 FSUtil::GetPreviousMediaIDL( const CMdEHarvesterSession* aMdeSession,
											TChar aDrive )
	{
	RArray<TMdEMediaInfo> presentMedias;
	CleanupClosePushL( presentMedias );
	CMdEHarvesterSession* sess = (CMdEHarvesterSession*) aMdeSession;
	sess->GetPresentMediasL( presentMedias );

    TUint32 mediaid = 0;
    TInt count = presentMedias.Count();
    for( TInt i=0;i<count;i++ )
    	{
    	TMdEMediaInfo info = presentMedias[i];
    	if( info.iDrive == aDrive )
    		{
    		mediaid = info.iMediaId;
    		break;
    		}
    	}
    CleanupStack::PopAndDestroy( &presentMedias );
    
    return mediaid;
	}

inline TInt FSUtil::DriveNumber( const TDesC& aUri )
    {
    TChar ch = aUri[0];
    TInt drive = 0;
    TInt err = RFs::CharToDrive(ch, drive);
    if(err == KErrNone)
        {
        return drive;
        }
        
    return -1;
    }