os/graphics/fbs/fontandbitmapserver/sfbs/ShiftedFileStore.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/sfbs/ShiftedFileStore.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,73 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "ShiftedFileStore.h"
    1.20 +
    1.21 +/**
    1.22 +@internalComponent
    1.23 +CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset) method.
    1.24 +CFileStore::OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[])
    1.25 +method was used as an origin for the method's source code.
    1.26 +*/
    1.27 +CShiftedFileStore* CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset)
    1.28 +	{
    1.29 +	RFile file;
    1.30 +	User::LeaveIfError(file.Open(aFs, aName, aFileMode));
    1.31 +	CShiftedFileStore* store = FromL(file, aFileOffset);
    1.32 +	CleanupStack::PushL(store);
    1.33 +	return store;
    1.34 +	}
    1.35 +
    1.36 +/**
    1.37 +@internalComponent
    1.38 +CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset) method.
    1.39 +CFileStore::FromL(RFile& aFile,TFileStoreFactoryFunction aFunction) method was used as an origin
    1.40 +for the method's source code. The only difference is that RFileBuf::Attach is called with possibly
    1.41 +non-zero offset. The original implementation always calls RFileBuf::Attach with zero offset.
    1.42 +*/
    1.43 +CShiftedFileStore* CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset)
    1.44 +	{
    1.45 +	if (static_cast<TInt>(aFileOffset) < 0)
    1.46 +		User::Leave(KErrArgument);
    1.47 +	RFileBuf buf;
    1.48 +	buf.Attach(aFile, static_cast <TInt> (aFileOffset));
    1.49 +	buf.PushL();
    1.50 +	RReadStream stream(&buf);
    1.51 +	TCheckedUid chk;
    1.52 +	stream >> chk;
    1.53 +	CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType());
    1.54 +	if(store == NULL)
    1.55 +		User::Leave(KErrNotSupported);
    1.56 +	//CleanupStack::Pop(2) is called, because:
    1.57 +	//1) buf.PushL() - actually MStreamBuf::PushL() is called and it pushes buf 
    1.58 +	//                 into CleanupStack.
    1.59 +	//1) CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType()) -
    1.60 +	//                 FileStoreFactory::DirectLC() is called.
    1.61 +	CleanupStack::Pop(2);
    1.62 +	return static_cast <CShiftedFileStore*> (store);
    1.63 +	}
    1.64 +
    1.65 +/**
    1.66 +@internalComponent
    1.67 +Constructor. Prevents compiler warnings.
    1.68 +Actually, CShiftedFileStore instance is newer created. CFileStore or CDirectFileStore
    1.69 +instance is created and downcasted to CShiftedFileStore. It is possible to do that:
    1.70 +CShiftedFileStore doesn't have data members at all.
    1.71 +*/
    1.72 +CShiftedFileStore::CShiftedFileStore(RFile& aFile) :
    1.73 +	CDirectFileStore(aFile)
    1.74 +	{
    1.75 +	}
    1.76 +