diff -r 000000000000 -r 8e480a14352b messagingfw/msgsrvnstore/server/src/CCopyOneFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/msgsrvnstore/server/src/CCopyOneFile.cpp Mon Jan 18 20:36:02 2010 +0200 @@ -0,0 +1,119 @@ +// Copyright (c) 2000-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: +// + +#include "CCopyOneFile.h" + +const TInt KCopyFileBufferSize=32768; + +CCopyOneFile* CCopyOneFile::NewL(RFs &aFs) + { + CCopyOneFile *self=new (ELeave) CCopyOneFile(aFs); + CleanupStack::PushL(self); + self->ConstructL(); + CActiveScheduler::Add(self); + CleanupStack::Pop(); + return(self); + } + +void CCopyOneFile::Copy(const TFileName &aFrom, const TFileName &aTo,TRequestStatus& aStatus) + { + aStatus=KRequestPending; + iReportStatus=&aStatus; + TInt error=iFrom.Open(iFs,aFrom,EFileRead|EFileShareReadersOnly); + if(error==KErrNone) + { + error=iTo.Replace(iFs,aTo,EFileWrite|EFileShareExclusive); + if(error==KErrNone) + { + iFrom.Read(*iFileBuffer,KCopyFileBufferSize,iStatus); + iReading=ETrue; + SetActive(); + } + } + if(error!=KErrNone) + Complete(error); + } + +void CCopyOneFile::Copy(RFile& aFrom, RFile& aTo, TRequestStatus& aStatus) + { + aStatus=KRequestPending; + iReportStatus=&aStatus; + + iFrom = aFrom; + iTo = aTo; + + iFrom.Read(*iFileBuffer,KCopyFileBufferSize,iStatus); + iReading=ETrue; + SetActive(); + } + +void CCopyOneFile::RunL() + { + User::LeaveIfError(iStatus.Int()); + + if(iReading==EFalse) + { + if(iFileBuffer->Length(); + } + +CCopyOneFile::CCopyOneFile(RFs &aFs) : CActive(EPriorityStandard), iFs(aFs) + { + } + +CCopyOneFile::~CCopyOneFile() + { + Cancel(); + delete iFileBuffer; + } + +void CCopyOneFile::Complete(TInt aError) + { + iFrom.Close(); + iTo.Close(); + if(iReportStatus) + User::RequestComplete(iReportStatus,aError); + } +