sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmdinitramdrive.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 11:09:10 +0300
branchRCL_3
changeset 20 1ddbe54d0645
parent 0 4e1aa6a622a0
permissions -rw-r--r--
Revision: 201031 Kit: 201033

// Copyright (c) 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: Custom command to intialise the RAM drive.
//

#include "cmdinitramdrive.h"

//RAM drive directories created on every boot
_LIT(KRAMDriveTempPath, "\\system\\temp\\");
_LIT(KWAPCachePath, "\\wap\\");
_LIT(KCBSCachePath, "\\cbs\\");

CCustomCmdInitRamDrive* CCustomCmdInitRamDrive::NewL()
	{
	return new (ELeave) CCustomCmdInitRamDrive();
	}

CCustomCmdInitRamDrive::~CCustomCmdInitRamDrive()
    {
    }

CCustomCmdInitRamDrive::CCustomCmdInitRamDrive()
    {
    }

TInt CCustomCmdInitRamDrive::Initialize(CSsmCustomCommandEnv* aCmdEnv)
    {
    //Using the RFs from the command environment
    iFs.SetHandle(aCmdEnv->Rfs().Handle());
    return KErrNone;
    }

void CCustomCmdInitRamDrive::Execute(const TDesC8& /*aParams*/, TRequestStatus& aRequest)
    {
    aRequest = KRequestPending;
    TChar ramDriveLetter;
    // Ignore errors
    iFs.DriveToChar( EDriveD, ramDriveLetter );

    //Buffer containing drive id (drive letter + :)
    TBuf<2> driveName;
    driveName.Append(ramDriveLetter);
    driveName.Append(TChar(':'));

    TParse parse;
    // Ignore errors.
    parse.SetNoWild(KRAMDriveTempPath, &driveName, NULL);
    iFs.MkDirAll(parse.DriveAndPath());

    parse.SetNoWild(KWAPCachePath, &driveName, NULL);
    iFs.MkDirAll(parse.DriveAndPath());

    parse.SetNoWild(KCBSCachePath, &driveName, NULL);
    iFs.MkDirAll(parse.DriveAndPath());

    TRequestStatus* request = &aRequest;
    User::RequestComplete(request, KErrNone);
    }

void CCustomCmdInitRamDrive::ExecuteCancel()
    {
    //Nothing to cancel
    }

void CCustomCmdInitRamDrive::Close()
    {
    }

void CCustomCmdInitRamDrive::Release()
    {
	delete this;
    }