os/graphics/fbs/fontandbitmapserver/sfbs/ShiftedFileStore.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "ShiftedFileStore.h"
    17 
    18 /**
    19 @internalComponent
    20 CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset) method.
    21 CFileStore::OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[])
    22 method was used as an origin for the method's source code.
    23 */
    24 CShiftedFileStore* CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset)
    25 	{
    26 	RFile file;
    27 	User::LeaveIfError(file.Open(aFs, aName, aFileMode));
    28 	CShiftedFileStore* store = FromL(file, aFileOffset);
    29 	CleanupStack::PushL(store);
    30 	return store;
    31 	}
    32 
    33 /**
    34 @internalComponent
    35 CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset) method.
    36 CFileStore::FromL(RFile& aFile,TFileStoreFactoryFunction aFunction) method was used as an origin
    37 for the method's source code. The only difference is that RFileBuf::Attach is called with possibly
    38 non-zero offset. The original implementation always calls RFileBuf::Attach with zero offset.
    39 */
    40 CShiftedFileStore* CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset)
    41 	{
    42 	if (static_cast<TInt>(aFileOffset) < 0)
    43 		User::Leave(KErrArgument);
    44 	RFileBuf buf;
    45 	buf.Attach(aFile, static_cast <TInt> (aFileOffset));
    46 	buf.PushL();
    47 	RReadStream stream(&buf);
    48 	TCheckedUid chk;
    49 	stream >> chk;
    50 	CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType());
    51 	if(store == NULL)
    52 		User::Leave(KErrNotSupported);
    53 	//CleanupStack::Pop(2) is called, because:
    54 	//1) buf.PushL() - actually MStreamBuf::PushL() is called and it pushes buf 
    55 	//                 into CleanupStack.
    56 	//1) CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType()) -
    57 	//                 FileStoreFactory::DirectLC() is called.
    58 	CleanupStack::Pop(2);
    59 	return static_cast <CShiftedFileStore*> (store);
    60 	}
    61 
    62 /**
    63 @internalComponent
    64 Constructor. Prevents compiler warnings.
    65 Actually, CShiftedFileStore instance is newer created. CFileStore or CDirectFileStore
    66 instance is created and downcasted to CShiftedFileStore. It is possible to do that:
    67 CShiftedFileStore doesn't have data members at all.
    68 */
    69 CShiftedFileStore::CShiftedFileStore(RFile& aFile) :
    70 	CDirectFileStore(aFile)
    71 	{
    72 	}
    73