diff -r 2fb8b9db1c86 -r d55eb581a87c baseport/syborg/svphostfs/fs/svphostfil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baseport/syborg/svphostfs/fs/svphostfil.cpp Tue Aug 04 10:28:23 2009 +0100 @@ -0,0 +1,213 @@ +/* +* 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 the License "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: +* +*/ + +#include +#include +#include +#include + +#include "svphostfsy.h" + + + +////////////////////////////////////////////////////////////////////////// +// CSVPHostFileCB // +////////////////////////////////////////////////////////////////////////// + +CSVPHostFileCB::CSVPHostFileCB() +// +// Constructor +// + { + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::CSVPHostFileCB()")); + + __DECLARE_NAME(_S("CSVPHostFileCB")); + } + +CSVPHostFileCB::~CSVPHostFileCB() +// +// Destructor +// + { + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::~CSVPHostFileCB()")); + if ((TInt)iHandle == KErrBadHandle) return; + + SVP_HOST_FS_DEVICE().FileClose(Drive().DriveNumber(), iHandle); + } + +TBool CSVPHostFileCB::IsRomDrive() const +// +// Returns ETrue if the drive number == EDriveZ +// + { + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::IsRomDrive()")); + return(EFalse); + } + + +void CSVPHostFileCB::CheckPos(TInt /*aPos*/) + { + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::CheckPos()")); + } + +void CSVPHostFileCB::ReadL(TInt aPos,TInt& aLength ,const TAny* aDes , const RMessagePtr2& aMessage) + { + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::ReadL(%d,%d)"), aPos, aLength); + + TInt n = 0; + TInt pos=aPos; + TInt len=aLength; + TBuf8<0x400> buf; + + if (aMessage.Handle() == KLocalMessageHandle) + ((TPtr8* )aDes)->SetLength(0); + + TUint driveNumber = Drive().DriveNumber() ; + while (len) + { + TInt s=Min(len,buf.MaxLength()); + TSVPHostFsFileReadInfo info(driveNumber, iHandle,s,pos+n,(char*)buf.Ptr()); + + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::ReadL pos %d s %d p 0x%08x"), pos+n, s, buf.Ptr()); + + User::LeaveIfError(SVP_HOST_FS_DEVICE().FileRead(info)); + + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::ReadL read %d bytes"), info.iLength); + + buf.SetLength(info.iLength); + + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::ReadL set buf length")); + + if (aMessage.Handle() == KLocalMessageHandle) + ((TPtr8* )aDes)->Append(buf); + else + aMessage.WriteL(0,buf,n); + + n+=info.iLength; + + if (((TInt)info.iLength) buf; + TUint driveNumber = Drive().DriveNumber() ; + while (len) + { + TInt s=Min(len,buf.MaxLength()); + + if (aMessage.Handle() == KLocalMessageHandle) + buf.Copy( ((TPtr8* )aDes)->MidTPtr(n, s) ); + else + aMessage.ReadL(0,buf,n); + + TSVPHostFsFileWriteInfo info(driveNumber, iHandle,s,pos+n,(char*)buf.Ptr()); + + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::WriteL pos %d s %d p 0x%08x"), pos+n, s, buf.Ptr()); + + User::LeaveIfError(SVP_HOST_FS_DEVICE().FileWrite(info)); + + DP(_L("** (SVPHOSTFIL) CSVPHostFileCB::WriteL wrote %d bytes"), info.iLength); + + if (((TInt)info.iLength)